Pass a variable to an Assetic asset URL in Symfony2

ed209 picture ed209 · Nov 27, 2011 · Viewed 17.5k times · Source

Is there a way to pass a variable to the Assetic method in templates

{% stylesheets
    '@SomeExampleBundle/Resources/views/ SOMEVAR /css/*'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

So what I want to do is pass SOMEVAR from the controller.

Answer

Chopchop picture Chopchop · Apr 29, 2012

It is possible through this way :

<link rel="stylesheet" href="{{ asset('bundles/yourbundle/css/'~ SOMEVAR ~'/css/' ) }}" />