Re: [flask] how to export an function to the template
- From:
- Jérôme Pigeot
- Date:
- 2011-05-25 @ 12:52
You have to write a jinja2 filter for that :
http://flask.pocoo.org/docs/templating/#registering-filters
<http://flask.pocoo.org/docs/templating/#registering-filters>regards,
Jérôme.
2011/5/25 Alex <gfreezy@gmail.com>
> I have defined a function named format_time().How can i export it to the
> template so i can use the function in the template.
> Use the 'g' object or something else?
> Thanks.
>
Re: [flask] how to export an function to the template
- From:
- Jackie Lee
- Date:
- 2011-05-25 @ 14:41
use template_filter?
@app.template_filter()
def reverse(s):
return s[::-1]
http://flask.pocoo.org/docs/api/#flask.Flask.template_filter
2011/5/25 Jérôme Pigeot <j.pigeot@gmail.com>:
> You have to write a jinja2 filter for that
> : http://flask.pocoo.org/docs/templating/#registering-filters
> regards,
> Jérôme.
>
> 2011/5/25 Alex <gfreezy@gmail.com>
>>
>> I have defined a function named format_time().How can i export it to the
>> template so i can use the function in the template.
>> Use the 'g' object or something else?
>> Thanks.
>
>
--
Jackie
Re: [flask] how to export an function to the template
- From:
- Alex
- Date:
- 2011-05-25 @ 14:47
Thanks. The problem is solved.
2011/5/25 Jackie Lee <jackie.space@gmail.com>
> use template_filter?
>
> @app.template_filter()
> def reverse(s):
> return s[::-1]
>
> http://flask.pocoo.org/docs/api/#flask.Flask.template_filter
>
> 2011/5/25 Jérôme Pigeot <j.pigeot@gmail.com>:
> > You have to write a jinja2 filter for that
> > : http://flask.pocoo.org/docs/templating/#registering-filters
> > regards,
> > Jérôme.
> >
> > 2011/5/25 Alex <gfreezy@gmail.com>
> >>
> >> I have defined a function named format_time().How can i export it to the
> >> template so i can use the function in the template.
> >> Use the 'g' object or something else?
> >> Thanks.
> >
> >
>
>
>
> --
> Jackie
>