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

我得到的错误是:

参数必须用逗号分隔。","第 9 行 appappBundle:Default:index.html.twig 中的值“{”的意外标记“标点符号”(“标点符号”应为 value )

4

1 回答 1

2

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

 <link id = "hojaestilo" rel = "stylesheet" type = "text/css" href = "{{asset ('bundles/appapp/css/themes/' ~ app.user.tema ~ '/jquery-wijmo.css')}}" media ="screen">
于 2013-01-20T12:06:36.683 回答