Twig (template engine)
Twig is a free and open-source template engine for PHP.[src] Its syntax originates from Jinja and Django templates.[src] It is licensed under the BSD License and maintained by Fabien Potencier.[src] The initial version was created by Armin Ronacher.[src] Symfony comes with bundled support for Twig as its default template engine since version 2.[src] The same template language is used by the Nunjucks template engine, thus Nunjucks is also supported by the following tools.[src]
Twig is a free and open-source template engine for PHP.[src] Its syntax originates from Jinja and Django templates.[src] It is licensed under the BSD License and maintained by Fabien Potencier.[src] The initial version was created by Armin Ronacher.[src] Symfony comes with bundled support for Twig as its default template engine since version 2.[src] The same template language is used by the Nunjucks template engine, thus Nunjucks is also supported by the following tools.[src] {% set foo = 'bar' %} , to assign.[src] {% if i is defined and i == 1%} ...[src] {% endif %} : condition.[src] {% for i in 0..10 %} ...[src] {% endfor %} : counter in a loop.[src] Unlike in base PHP, Twig variables do not start with a dollar sign.[src] The apostrophe (') is the escape character.[src] To create an iterative array: {% set myArray = [1, 2] %} An associative array: {% set myArray = {'key': 'value'} %} {% extends "base.html" %} {% block navigation %} {% for item in navigation %} {% if item.level == 2 %} {% endif %} {% endfor %} {% endblock navigation %}[src]
20 sentences · 20 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Twig (template engine)." encyclopegia.org, 2026, https://encyclopegia.org/wiki/twig-template-engine. Accessed 01 December 2026.
Chicago
"Twig (template engine)." encyclopegia.org. Accessed December 1, 2026. https://encyclopegia.org/wiki/twig-template-engine.
APA
encyclopegia.org. (2026). Twig (template engine). Retrieved December 1, 2026, from https://encyclopegia.org/wiki/twig-template-engine
Accessed December 1, 2026 · CC BY-SA 4.0 · citation page · JSON