根据用户的区域设置包含带变量的模板

时间:2015-07-10 00:18:00

标签: symfony twig

我想根据用户的区域设置包含模板。 这是静态代码,它工作正常

{% include 'AppBundle:Frontend:content_en.html.twig' %}

我试过这个,但它不起作用:

{% include {{ 'AppBundle:Frontend:content_' ~ app.request.locale ~ '.html.twig'  }} %}

这是错误

A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses 
(unexpected token "punctuation" of value "{" in AppBundle:Frontend:index.html.twig at line 18

1 个答案:

答案 0 :(得分:2)

解决

{{ include ('AppBundle:Frontend:content_' ~ app.request.locale ~ '.html.twig')  }}