Benjamin
Benjamin

Reputation: 1104

Using Twig Variables inside config.yml

Is it possible to use variable values for defining new twig globals in a configuartion-yml-file?

The situation is, that we want to define the domain name at the one hand and at the other define often used paths (but using the already defined variable instead of writing the server name again at the beginning of each path).

So is it possible to make the config-file look something like the following code?

twig:
    globals:
       serv: http://www.server.de
       path: {{serv}}/path/

If not, what would be a reasonable alternative?

Thx in advance

Upvotes: 1

Views: 322

Answers (1)

Mikhail Prosalov
Mikhail Prosalov

Reputation: 4345

I suggest to use parameters.yml to define configuration params.

parameters.yml

serv: "http://www.server.de"

config.yml

twig:
    globals:
       serv: "%serv%"
       path: "%serv%/path/"

Upvotes: 3

Related Questions