Combining Assetic Resources across inherited templates

You can actually do the following:

In layout.html.twig (or whatever your layout is)

{% block stylesheets %}
    {% stylesheets 'your_assets_here' %}
         <link rel="stylesheet" href="https://stackoverflow.com/questions/6958970/{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

And in any template that extends that layout:

{% block stylesheets %}
    {{ parent() }}
    {% stylesheets 'additional_assets_here' %}
         <link rel="stylesheet" href="https://stackoverflow.com/questions/6958970/{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

Then you wouldn’t need to retype all the old assets as suggested by Nemanja Niljkovic

Leave a Comment