Template Engine Basics
Pubvana uses a custom .tpl template engine — not Twig, Blade, or Smarty. This article is a quick introduction for theme developers.
Three Syntax Forms
1. Output: {{ expression }}
Outputs a variable or expression, HTML-escaped by default:
{{ page_title }}
{{ post.title }}
{{ post.created_at | date "M j, Y" }}
{{ items | count }}
2. Raw Output: {! expression !}
Outputs without HTML escaping. Use for helper calls and pre-rendered HTML:
{! csrf_field !}
{! widget_area "sidebar" !}
{! theme_url "assets/css/style.css" !}
{! render_content post !}
{! pager !}
3. Tags: {% tag %}
Control structures — no output:
{% extends "layout.tpl" %}
{% block content %}...{% endblock %}
{% include "partials/post-card.tpl" %}
{% for post in posts %}...{% endfor %}
{% if condition %}...{% endif %}
Available Filters
| Filter | Example | Description |
|---|---|---|
date | {{ ts | date "Y-m-d" }} | Format a date/timestamp |
number_format | {{ num | number_format 2 }} | Format a number |
nl2br | {{ text | nl2br }} | Newlines to <br> |
count | {{ list | count }} | Count array items |
excerpt | {{ body | excerpt 150 }} | Truncate to N characters |
default | {{ val | default "–" }} | Value or fallback if empty |
raw | {{ html | raw }} | Output without escaping |
strtolower | {{ str | strtolower }} | Lowercase |
strip_tags | {{ html | strip_tags }} | Remove HTML tags |
Layout Inheritance
{% extends "layout.tpl" %}
{% block content %}
<h1>{{ page_title }}</h1>
{% endblock %}
Loops and Conditionals
{% for post in posts %}
<h2>{{ post.title }}</h2>
{% endfor %}
{% if theme_options.show_sidebar %}
{! widget_area "sidebar" !}
{% endif %}
Tag Functions (Raw Output)
| Tag function | Output |
|---|---|
{! csrf_field !} | Hidden CSRF input field |
{! lang "Key.name" !} | Translated string |
{! site_url "path" !} | Absolute URL to a path |
{! widget_area "sidebar" !} | Rendered widget area HTML |
{! theme_url "assets/img.png" !} | URL to a theme asset |
{! post_url slug !} | URL to a post by slug |
{! render_content entity !} | Rendered post/page body |
{! pager !} | Rendered pagination controls |