{% include ['page_detailed.html', 'page.html'] %} {# template.html will have access to the variables from the current context and the additional ones provided #} {% include 'template.html' with {'foo': 'bar'} %} {% include 'template.html' with {'foo': 'bar'} only %} {% set vars = {'foo': 'bar'} %} {% include 'template.html' with vars %} {% include 'sidebar.html' ignore missing %} {% include 'sidebar.html' ignore missing with {'foo': 'bar'} %} {% include 'sidebar.html' ignore missing only %} {{ include('sidebar.html') }} {% import "macros.twig" as macros %} {% from "macros.twig" import hello %} {% verbatim %}
{{ _self.input('password', '', 'password') }}
{% macro input(name, value, type = "text", size = 20) %}
{% endmacro %}
{%
Welcome to my awesome homepage.
Index
Table Of Contents
...
{{ parent() }}
{% endblock %}
{% set greeting = 'Hello ' %}
{% set name = 'Fabien' %}
{{ greeting ~ name|lower }} {# Hello fabien #}
{# use parenthesis to change precedence #}
{{ (greeting ~ name)|lower }} {# hello fabien #}
{# keys as string #}
{{{ 'foo': 'foo', 'bar': 'bar' }}}
{# keys as names (equivalent to the previous hash) #}
{{{ foo: 'foo', bar: 'bar' }}}
{# keys as integer #}
{{{ 2: 'foo', 4: 'bar' }}}
{# keys can be omitted if it is the same as the variable name #}
{{{ foo }}}
{# is equivalent to the following #}
{{{ 'foo': foo }}}
{# keys as expressions (the expression must be enclosed into parentheses) #}
{% set foo = 'foo' %}
{{{ (foo): 'foo', (1 + 1): 'bar', (foo ~ 'b'): 'baz' }}}
{% apply spaceless %}
<