Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Twig

< >

Twig is an open source template language created in 2009.

#322on PLDB 15Years Old 6kRepos
Download source code:
git clone https://github.com/mitsuhiko/twig
Homepage · Source Code · Wikipedia

Twig is a template engine for the PHP programming language. Its syntax originates from Jinja and Django templates. It's an open source product licensed under a BSD License and maintained by Fabien Potencier. Read more on Wikipedia...


Example from the web:
{% 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 %}
Example from Wikipedia:
{% 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 %}
apply autoescape block deprecated do embed extends flush for from if import include macro sandbox set use verbatim with endapply endautoescape endblock endembed endfor endif endmacro endsandbox endset endwith true false

Language features

Feature Supported Example Token
Conditionals ✓
Inheritance ✓
Booleans ✓ true false
Comments ✓ {# A comment #}
MultiLine Comments ✓ {# A comment #} {# #}

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v161.0.4