-------- Original-Nachricht --------
> Datum: Sun, 24 Jun 2012 10:27:37 -0700 (PDT)
> Von: Yonsy Solis <[email protected]>
> An: [email protected]
> Betreff: Jinja2 - any convention to register a filter or a function in 
> globals ?

> Hi
> 
> my case: i hate filters :)
> 
> well i hate the way that is used to invoke filters, in Django was 
> comprensible because you only have templatetags or filters to pass 
> parameters but in Jinja2 i can register a function in globals and pass 
> parameters, then, why i need filters ?
> 
> why we need to use
> 
> {{ var | filter() }}
> 
> when this can be
> 
> {{ filter(var) }}
> 
> ?
> 
> i presume that the convention is that the filter get *modified* the data 
> (the 1st parameter) and the function can be liberal with their output, but
> maybe with the functions merged in globals the implementation can be 
> simplified.

A good argument for the filter syntax is that its "pipeline" style
makes the flow and where the filter parameters belong much clearer for multiple 
filters:

{{ var | filter1(f1arg) | filter2(f2arg) | filter3(f3arg) }}

vs

{{ filter3(filter2(filter1(var, f1arg), f2arg), f3arg) }}

For filters without arguments, we also save punctuation.

Georg
-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                          
        
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en.

Reply via email to