Combining Assetic Resources across inherited templates

后端 未结 2 695
北恋
北恋 2020-12-02 20:52

We are building a new site using Symfony2, and Assetic looks very promising for resource management, in particular for combining and processing all js/css files together aut

2条回答
  •  余生分开走
    2020-12-02 21:21

    You can actually do the following:

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

    {% block stylesheets %}
        {% stylesheets 'your_assets_here' %}
             
        {% endstylesheets %}
    {% endblock %}
    

    And in any template that extends that layout:

    {% block stylesheets %}
        {{ parent() }}
        {% stylesheets 'additional_assets_here' %}
             
        {% endstylesheets %}
    {% endblock %}
    

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

提交回复
热议问题