kobylinski/twigenv

Twig 扩展,帮助在模板中定义特定环境的代码

dev-master 2013-06-02 16:55 UTC

This package is not auto-updated.

Last update: 2024-09-24 04:20:09 UTC


README

要更改配置,您必须删除缓存的模板。

用法

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