library twigenv
Twig extension, helps to define environment specific code in templates
kobylinski/twigenv
Twig extension, helps to define environment specific code in templates
- Sunday, June 2, 2013
- by kobylinski
- Repository
- 1 Watchers
- 2 Stars
- 163 Installations
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
Twig env tag
To change configuration you have to remove cached templates., (*1)
Usage
$twig = new Twig_Environment(new Twig_Loader_Filesystem('/path/to/templates'));
$twig->addTokenParser(new \TwigEnv\TokenParser('environment'));
{% env 'production' %}
<div>Production specific fragment of code</div>
{% env 'development' %}
<div>Development specific fragment of code</div>
{% env not 'production' %}
<div>Match any environment, except production</div>
{% env 'development_*' %}
<div>Match any environment with name starting with "development_"</div>
{% env not %}
<div>In unknown environment</div>
{% endenv %}