Extending stylesheet block

后端 未结 1 1085
半阙折子戏
半阙折子戏 2021-01-07 01:58

I have stylesheet block in base layout:

  {% stylesheets
       filter=\'cssrewrite\'
      \'bundles/static/css/main.css\'
  %}
  

        
相关标签:
1条回答
  • 2021-01-07 02:43

    Of course, it's possible.

    But currently, you don't have stylesheet block. You use the stylesheets tag.

    Just add a block like this:

    {% block stylesheets %}
        {% stylesheets
           filter='cssrewrite'
          'bundles/static/css/main.css'
        %}
            <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
    {% endblock %}
    

    And in others templates:

    {% block stylesheets %}
        {{ parent() }}
        {% stylesheets
           filter='cssrewrite'
          'another-css-file'
        %}
            <link rel="stylesheet" href="{{ asset_url }}" />
        {% endstylesheets %}
    {% endblock %}
    

    Don't forget to call the parent function to not override parent stylesheets.

    0 讨论(0)
提交回复
热议问题