You may define your own function and pass them as template globals.

template_globals = {
    "format_float":  lambda x:  ('%.2f' % x).replace('.', ',')
}
render = template.render(your_template_dir, globals=template_globals, 
base='layout')

Then in your templates you'll be able to use $format_float(x)

On Tuesday, October 2, 2012 3:01:13 PM UTC+4, Florian Lagg wrote:
>
> Hi, 
>
> I really enjoy the template engine, I use it some time now for web output, 
> and I try to use it to edit the xml-content of OpenOffice odt files (to be 
> able to design and generate pdf's, I'll open source this later.). 
>
> What I really would need, is to do some formatting I need to do in the 
> python statements in the template.
>
> Is there any way I could do something like that?
> ('%.2f' % 1.2333333).replace('.', ',')
> or something like:
> import locale
> locale.setlocale(locale.LC_ALL, 'FR')
> locale.format('%.2f', 1.2333333)
>
> Thanks in advance for your help, hope we have a solution to this! 
> Yours Florian.
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/webpy/-/14RpoQSNEBYJ.
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/webpy?hl=en.

Reply via email to