It's working like this:

>>> from google.appengine.ext.webapp import template
>>> foo = "{{bar}}"
>>> baz = template.Template(foo)
>>> baz.render(template.Context({'bar': "Hello, world!"}))
'Hello, world!'


On Sep 15, 7:26 pm, PatHaugen <[email protected]> wrote:
> I tried your example a few different ways, still get an error:
> AttributeError: 'str' object has no attribute 'render'
>
> bar = # pulled template from DB
> self.response.out.write(bar.render(template.Context(template_values)))
>
> Tried again using what you did on 'bar' before:
>
> foo = # pulled template from DB
> bar = template.Template(foo)
> self.response.out.write(bar.render(template.Context(template_values)))
>
> Not sure if 'template.Template()' takes a str and makes it into a
> 'template' able to be rendered, does this code work on your side?
>
> I even tried scrapping the way I pull the template and using your
> method:
> foo = db.get(templatekey).templatetext
>
> Before that, I had to do another DB query to pull the key value of the
> template I wanted, regardless it still failed...
>
> On Sep 15, 11:09 am, Wooble <[email protected]> wrote:
>
> > On Sep 15, 2:08 pm, Wooble <[email protected]> wrote:
>
> > > self.response.out.write(bar.render(template_values))
>
> > correction: you'll need to wrap template_values in template.Context();
> > template.render() does this for you automagically.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to