Is there a way to get the name of the current environment in a Twig template? I'd like to set some CSS style values depending on it.
You can get the current URL in Twig/Silex 2 like this: global. request. attributes. get('_route') .
In Twig templates variables can be accessed using double curly braces notation {{ variableName }} .
To comment out one or more lines of code (or part of a line) use the the {# #} syntax. comment. Comments aren't just useful for writing notes about your code.
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" %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With