[Flask] commafy filter

David Lord davidism at gmail.com
Fri Apr 15 01:47:27 EDT 2016


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
>
>
>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160414/f7ec6407/attachment-0001.html>


More information about the Flask mailing list