[Flask] commafy filter

Gabor Szabo gabor at szabgab.com
Fri Apr 15 02:39:19 EDT 2016


Nice. Thank you all!

Gabor

On Fri, Apr 15, 2016 at 8:47 AM, David Lord <davidism at gmail.com> wrote:

> You can register your own template filters with your app. They will be
> available in any templates rendered with the app’s Jinja env.
>
> @app.template_filter()def commafy(value):
>         return '{:,}'.format(value)
>
> On 04/14/2016 10:06 PM, Gabor Szabo wrote:
>
> Hi,
>
> is there a filter in Jinja to commafy numbers? That is, to put a comma
> in-front of ever 3 digits?
>
> I could not find one yet, so I've been using this expression all over the
> place:
>
> {{ "{:,}".format( value ) }}
>
> but I think it would be nicer if I could write
>
> {{ value | commafy }}
>
>
>
> regards
>   Gabor
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160415/0af2b1c9/attachment.html>


More information about the Flask mailing list