Simple function call:
{{ pngout("images/logo.png") }}Simple filter call:
{{ "images/logo.png"|pngout }}Simple function call:
{{ pngout("images/logo.png") }}Simple filter call:
{{ "images/logo.png"|pngout }}What would the output of pngout() look like? If it's an url then the function should probably be called pngurl().
I'm all in favor of filters, it seems to be a better fit with the actual operation.
A filter is better when the value is being filtered/altered (upper cased, encoded, ...). So, the returned value is semantically the same as the input. Here, I think it's a function as the path is just an input value and the output is very different.
I agree that a function is more appropriate for the reason Fabien mentioned though I still think that
a) if the function outputs an url it should be renamed to pngurl() to make it more explicit what it is the function actually "out"puts.
b) Are there going to be multiple function for each mime type? What about a function asset_url() that could be used for all types (perhaps with an optional second argument to specify the type explicitly if its not one of the standard types)?
If it's an URL I'm all in favor of making it a function. If it's going to allow image data/uri then I'd like it to be a filter.
I guess if all it does is output a URL than one function for all asset types is fine.
I've decided to go with a function because this should be used instead of Symfony2's
asset()function.