How do I read configuration settings from Symfony2 config.yml in twig template?

前端 未结 2 1559
南笙
南笙 2021-02-05 13:45

In controller i can read like this

$this->container->getParameter(\'test\');

But how get this var \"test\" in my twig template?

2条回答
  •  余生分开走
    2021-02-05 14:04

    Yes, you can create your own Twig extension, in this class you can override getGlobals() and return an array with your global variables.

    Or you can create a Twig method in this extension param($value) to return the right parameter.

提交回复
热议问题