Timo Timo - 1 year ago 351
Twig Question

How to get config parameters in Symfony2 Twig Templates

I have a Symfony2 Twig template. I want to output the value of a config parameter in this twig template (a version number). Therefore I defined the config parameter like this:

app.version: 0.1.0

I'm able to use this config parameter in Controllers but I have no clue how to get it in my Twig template.

Answer Source

Easily, you can define in your config file:

        version: "0.1.0"

And access it in your template with

{{ version }}

Otherwise it must be a way with an Twig extension to expose your parameters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download