有没有一种方法可以在 Twig 模板中获得当前环境的名称?我想根据它设置一些 CSS 样式值。
http://symfony.com/doc/current/templating/app_variable.html:
<p>Application Environment: \{\{ app.environment }}</p>
Use
app.environment
e.g.
{% extends app.environment == 'dev' ? "::dev_layout.html.twig" : "::layout.html.twig" %}
Or you can use
app.debug
This returns true if debug is enabled. This is usually the case in the dev environment, however debug can be enabled in any of the environments... prod, test, dev, etc....