Message from discussion
Jinja2 - any convention to register a filter or a function in globals ?
Date: Sun, 24 Jun 2012 10:27:37 -0700 (PDT)
From: Yonsy Solis <yonsy.so...@gmail.com>
To: pocoo-libs@googlegroups.com
Message-Id: <7be8bd23-7681-411f-96c4-58f9d7d7c70b@googlegroups.com>
Subject: Jinja2 - any convention to register a filter or a function in
globals ?
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_1216_10593644.1340558857103"
------=_Part_1216_10593644.1340558857103
Content-Type: multipart/alternative;
boundary="----=_Part_1217_7564638.1340558857103"
------=_Part_1217_7564638.1340558857103
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
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.
exist any side effect if i register my filters like functions in my global
space to be invoked like functions ?
sorry if this question was asked before but i search in google and archives
and dont find any related :(
P.D. sorry for my bad english
--
Yonsy Solis
------=_Part_1217_7564638.1340558857103
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
Hi<br><br>my case: i hate filters :)<br><br>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 ?<br><br>why we need to use<br><br>{{ var | filter() }}<br><br>when this can be<br><br>{{ filter(var) }}<br><br>?<br><br>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.<br><br>exist any side effect if i register my filters like functions in my global space to be invoked like functions ?<br><br>sorry if this question was asked before but i search in google and archives and dont find any related :( <br><br>P.D. sorry for my bad english <br><br>--<br>Yonsy Solis<br><br>
------=_Part_1217_7564638.1340558857103--
------=_Part_1216_10593644.1340558857103--