我想在Symfony2项目的twig模板中嵌入带有资产的不同样式表文件.使用的样式表取决于用户的主题设置.
我用了
{% stylesheets
'@CuteFlowCoreBundle/Resources/public/css/application.css'
'@CuteFlowCoreBundle/Resources/public/css/theme/'~app.session.get('cuteflow_theme')~'/application.css'
%}
{% endstylesheets %}
但这会引发错误:
Unexpected token "operator" of value "~" in "CoreBundle::layout.html.twig"
我也试过以下.但这也没有帮助.
{% set theme = '@CuteFlowCoreBundle/Resources/public/css/theme/'~app.session.get('cuteflow_theme')~'/application.css' %}
{% stylesheets
'@CuteFlowCoreBundle/Resources/public/css/application.css'
theme
%}
{% endstylesheets %}
有什么想法可以做到这一点?