Element

Element

{% element %} (block)

Outputs a block-level HTML element with nested content and sanitized attributes.

{% element name attributes? / %}

{% element
name
 
HTML element tag name
attributes
 
Key:value pairs with unique keys. May use the variable arguments syntax. Attributes to include on the resulting HTML element. Each attribute must have a string value. The keys will be output as-is and the values will be HTML encoded.
%}

{% endelement %}

{% element / %} (self-closing)

Outputs a sanitized HTML element that is self-closed.

{% element name attributes? / %}

{% element
name
 
HTML element tag name
attributes
 
Key:value pairs with unique keys. May use the variable arguments syntax. Attributes to include on the resulting HTML element. Each attribute must have a string value. The keys will be output as-is and the values will be HTML encoded.
%}

Examples

Output self-closing input element

Copy
{% element 'input' type:'text' name:'username' placeholder:'Username' required:required / %}

Output content inside div

Copy
{% element 'div' id:'maincontent' class:'container wide' %}
{% include '/maincontent' %}
{% endelement %}