Languages Features Creators CSV Resources Challenges Add Language
GitHub icon

Twig

Twig - Template language

< >

Twig is a template language created in 2009.

#357on PLDB 14Years Old 611Users
0Books 0Papers 6kRepos

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 %}

Keywords in Twig

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 Token Example
Conditionals ✓
Inheritance ✓
Booleans ✓ true false
Comments ✓
{# A comment
#}
MultiLine Comments ✓ {# #}
{# A comment
#}
saltstack.html · twig.html · gap.html

View source

- Build the next great programming language · Search · Day 213 · About · Blog · Acknowledgements · Traffic · Traffic Today · GitHub · feedback@pldb.com