2015-07-10 46 views
2

我想包括取决于用户的区域设置的模板。 这是静态代码,它工作正常包含具有取决于用户的区域设置的变量的模板

{% 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 

回答

2

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