On Wed, Mar 15, 2017 at 8:57 AM, Shane Cleveland <shane.clevel...@gmail.com>
wrote:

> I am needing to use a template as a string, so I can send it as an email
> from within my application.
>
> The web.py docs show how to do this:
>
> template = "$def with (name)\nHello $name"
> hello = web.template.Template(template)
> print hello('world')
>
> But I need to use the round() function, which is not supported within the
> template. I was able to successfully pass this as a global when rendering
> the html in a browser, but I have been able to figure out how to do it with
> the template as a string.
>
> Any ideas?
>

Here is what you need to do:

hello = web.template.Template(template, globals={"round": round})

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at https://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to