GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

Twig (template engine)

Twig is a free and open-source template engine for PHP. Its syntax originates from Jinja and Django templates. It is licensed under the BSD License and maintained by Fabien Potencier. The initial version was created by Armin Ronacher. Symfony comes with bundled support for Twig as its default template engine since version 2. The same template language is used by the Nunjucks template engine, thus Nunjucks is also supported by the following tools. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

Twig is a free and open-source template engine for PHP. Its syntax originates from Jinja and Django templates. It is licensed under the BSD License and maintained by Fabien Potencier. The initial version was created by Armin Ronacher. Symfony comes with bundled support for Twig as its default template engine since version 2. The same template language is used by the Nunjucks template engine, thus Nunjucks is also supported by the following tools. {% set foo = 'bar' %} , to assign. {% if i is defined and i == 1%} ... {% endif %} : condition. {% for i in 0..10 %} ... {% endfor %} : counter in a loop. Unlike in base PHP, Twig variables do not start with a dollar sign. The apostrophe (') is the escape character. 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 %}

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Twig (template engine)". 1788590012. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1373322931

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·