faisbu
faisbu

Reputation: 275

symfony2 twig variable

I'm trying to change the href attribute of a link of css. The problem is it does not show the varible {{app.user.tema}} the problem of the quotes.

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

The error I get is:

Arguments must be separated by a comma. Unexpected token "punctuation" of value "{" ("punctuation" expected with value ",") in appappBundle:Default:index.html.twig at line 9

Upvotes: 1

Views: 1147

Answers (1)

FWrnr
FWrnr

Reputation: 361

Joining the variable and the string with ~ may work:

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

Upvotes: 2

Related Questions