Default template engine

The default template engine has a simple, intuitive syntax inspired by twig. We do not provide complete compatibility to twig.

Reserved word

Some names are used to provide default functionality and are not allowed to be used.

node, cms

Variables

Variables are escaped by default

{{ variable }}
{{ node.meta.title }}

Printing the unescaped content of a variable.

{{ variable | raw }}

assign variables

{% assign variable = 5 %}

if-elseif-else

{% if <expression> %}
{% elseif <expression> %}
{% else %}
{% endif %}

for

{% for item in items %}
    {{ look.index }}
{% endfor %}

include

{% include 'fragement.html' %}

macros

Definition and usage of a macro

{% macro hello(name) %}
    Hello {{ name }}
{% endmacro %}

{{ hello('CondationCMS') }}

Or import the macro in another template

{% import 'macros.html' %}

{{ hello('CondationCMS') }}

components

The default template engines allow the registration of custom components.

{[ ext:component param=12 param2="text value" ]}

{[ /ext:component ]}

comments

{# this is a comment #}

layouts with extends and blocks

in base template

{% block header %}
{% endblock %}

{% block content %}
{% endblock %}

in child template


{% extends 'base.html' %}

{% block header %}
    Override default block
{% endblock %}

{% block content %}
    Override default block
{% endblock %}