kriswallsmith / assetic

Asset Management for PHP
MIT License
3.76k stars 559 forks source link

Possible to pass parameters to filters? #375

Open baldurrensch opened 11 years ago

baldurrensch commented 11 years ago

Hi,

I have a question: Is it possible to pass additional parameters from the twig template to a filter? I am in the process of writing a new filter, and I need to be able to pass along parameters from the twig template for the filter. I haven't really seen how to do that. I am fine if that is passed along through the asset to the filter.

Example:

{% javascripts '%kernel.root_dir%/../vendor/acme/ember/common/specs/*.js'
    filter="minispade"
    vars= ["foo", "bar"]
    output="js/common.js"
%}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

(The minispade filter I am in the process of writing. I want to pass something like the the "foo" and "bar". Ideally "foo" => "bar". Is that at all possible?

stof commented 11 years ago

You may use asset variables. See http://jmsyst.com/blog/asset-variables-in-assetic for an explanation