On Sun, Sep 19, 2010 at 9:30 AM, Armin Ronacher <[email protected]
> wrote:
> Hi,
>
>
> On 2010-09-19 2:21 AM, kevin wrote:
>
>> if a variable is None, the text 'None' gets output/printed in the html.
>> is possible to have empty string instead of 'None'?
>> thanks
>>
> Yes, you can override the finalize method or patch it on the environment:
>
>
> def silent_none(value):
> if value is None:
> return ''
> return value
>
> from jinja2 import Environment
> env = Environment()
> env.finalize = silent_none
>
thanks for the info
> I however recommend being explicit instead of a finalizer:
>
> {{ variable or '' }}
>
this seems easier and better, i did not know i could do this in jinja2
jinja2 rocks, thanks
--
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.