Twig (template engine)

Twig
Original author(s) Armin Ronacher,[1] Fabien Potencier
Developer(s) SensioLabs
Initial release October 12, 2009 (2009-10-12)
Stable release 1.24.0[2] / January 26, 2016 (2016-01-26)
Development status Active
Written in PHP
Operating system Cross-platform
Type Template engine
License BSD License
Website twig.sensiolabs.org

Twig is a template engine for the PHP programming language. Its syntax originates from Jinja and Django templates.[3] It's an open source product[4] licensed under a BSD License and maintained by Fabien Potencier. The initial version was created by Armin Ronacher. Symfony2 PHP framework comes with a bundled support for Twig as its default template engine.[5]

Example

The example below demonstrates some basic features of Twig.

{% extends "base.html" %}
{% block navigation %}
    <ul id="navigation">
    {% for item in navigation %}
        <li>
            <a href="{{ item.href }}">
                {% if item.level == 2 %}&nbsp;&nbsp;{% endif %}
                {{ item.caption|upper }}
            </a>
        </li>
    {% endfor %}
    </ul>
{% endblock navigation %}

Twig defines three kinds of delimiters:

Features

See also

References

External links

This article is issued from Wikipedia - version of the Sunday, April 03, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.