首页 文章

symfony2 twig变量

提问于
浏览
1

我正在尝试更改css链接的href属性 . 问题是它没有显示引号的问题 {{app.user.tema}} .

{% block tema%}
   {% if app.user.tema %}
     <link id = "hojaestilo" rel = "stylesheet" type = "text / css" href = "{{asset ('bundles / appapp / css / themes / {{app.user.tema}} / jquery-wijmo.css')}} "media =" screen ">
    {% endif %}
{% endblock %}

我得到的错误是:

参数必须用逗号分隔 . appappBundle中值为“{”(“标点符号”预期值为“,”)的意外标记“标点符号”:默认值:第9行的index.html.twig

1 回答

  • 2

    用〜连接变量和字符串可能有效:

    <link id = "hojaestilo" rel = "stylesheet" type = "text/css" href = "{{asset ('bundles/appapp/css/themes/' ~ app.user.tema ~ '/jquery-wijmo.css')}}" media ="screen">
    

相关问题