Skip to content

Loading…

How can I specify filter ordering? #141

Open
pschultz opened this Issue · 1 comment

2 participants

@pschultz

I implemented a custom filter that should pre-process my less files before they are compiled to css. The filter is called as expected, but it is invoked to late in the filter chain, after the less filter.

The service definition looks like this:

parameters:
    cm_lnf.customize_boostrap_filter.class: Classmarkets\LookAndFeelBundle\Assetic\Filter\CustomizeBootstrapFilter

services:
    assetic.filter.customize_boostrap:        # workaround for assetic to accept our filter
        class: "%cm_lnf.customize_boostrap_filter.class%"
        tags:
            - { name: assetic.filter, alias: customize_boostrap }                                                     

I tried to change the filter order by adding it to assetic.filters in app/config/config.yml (using the workaround described in #50) but that did not seem to change the order in which the filters are called:

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    node: "%node%"
    filters:
        cssrewrite: ~
        customize_boostrap:
            resource: 'assetic.xml'     # workaround for assetic to accept our filter
            apply_to: "bootstrap\.less$"
        less:
            node_paths: [ "%kernel.root_dir%/../node_modules" ]
            apply_to: "\.less$"

I also tried making the order explicit in the template, apparently without effect:

      {% stylesheets filter='customize_boostrap, less'
                       '@CMLnFBundle/Resources/public/less/bootstrap.less'
        %}
          <link href="{{ asset_url }}" type="text/css" rel="stylesheet">
        {% endstylesheets %}

Then I skimmed briefly through the code, but couldn't find a hint on how to influence filter priority / ordering. Is there an option that I missed? I can't quite believe that this is impossible.

@RyanThompson

I think it's probably alphabetical - but I too would love an answer to this one.

I have an instance that will be common in our system where the LessPHP filter is applied before our parser's filter and it jacks things up pretty bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.