{% if include_styles %} {% endif %}
{# Header Section with variable interpolation #}

{{ header_text | upper }}

{% if subheader %}

{{ subheader }}

{% endif %}
{# Navigation example with for loop #} {# Main content section with various template features #}
{# Conditionals #} {% if user %}

Welcome back, {{ user.name }}!

Last login: {{ user.last_login | date(format="%Y-%m-%d") }}

{% elif visitor_count > 0 %}

Welcome, visitor!

You are visitor number {{ visitor_count }}

{% else %}

Welcome to our site!

{% endif %} {# Macro definition and usage #} {% macro render_item(item, featured=false) %} {% endmacro render_item %} {# Items section with macro usage #}

Items ({{ items | length }})

{% for item in items %} {{ self::render_item(item=item, featured=item.id == featured_id) }} {% if not loop.last %}
{% endif %} {% endfor %}
{# Raw content that shouldn't be processed #} {% raw %}
The syntax {{ variable }} will not be processed in raw blocks. Neither will {% control %} structures.
{% endraw %} {# Includes #} {% include "partials/footer.tera" %} {# Inheritance example #} {% block content %}

This is the default content.

{% endblock content %} {# Set variables #} {% set text_color = dark_mode ? "#fff" : "#333" %} {% set items_count = items | length %}
We have {{ items_count }} items.
{# Filters with complex expressions #}

{{ "Hello, " ~ user.name | default(value="Guest") | upper }}

{{ items | filter(attribute="featured", value=true) | length }} featured items

{# With statement #} {% with %} {% set local_var = "Only visible in this scope" %}

{{ local_var }}

{% endwith %} {# Mathematical operations #}

Price: ${{ price }}

Tax ({{ tax_rate * 100 }}%): ${{ price * tax_rate }}

Total: ${{ price * (1 + tax_rate) }}

{# Boolean operations #} {% if user and user.is_admin or super_user %}
Admin panel
{% endif %}
{# Footer section with filters and includes #}