{% 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 %} {% if macros.hello is defined -%} OK {% endif %} {% if hello is defined -%} OK {% endif %} {% set foo = 'foo' %} {% set foo = [1, 2] %} {% set foo = {'foo': 'bar'} %} {% apply upper %} This text becomes uppercase {% endapply %} {% apply lower|escape('html') %} SOME TEXT {% endapply %} {{ list|join(', ') }} {{ name|striptags|title }} {% for i in 0..3 %} {{ i }}, {% endfor %} {% for i in range(0, 3) %} {{ i }}, {% endfor %} {% for i in range(low=1, high=10, step=2) %} {{ i }}, {% endfor %} {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }} {# versus #} {{ data|convert_encoding(from='iso-2022-jp', to='UTF-8') }} {{ "now"|date(null, "Europe/Paris") }} {{ "now"|date('d/m/Y H:i', timezone="Europe/Paris") }}
{% block head %}Welcome to my awesome homepage.
{% endblock %} {% block sidebar %}