On Fri, Feb 6, 2009 at 12:13 PM, Dalius Dobravolskas
<[email protected]> wrote:
> Hello,
>
> On Fri, Feb 6, 2009 at 9:03 PM, Jonathan Vanasco <[email protected]>
> wrote:
>>
>> ie -- instead of passing in a file, passing in a string?
>>
>> the only way i can think of this right now is with a tmpfile, and i'd
>> like to avoid that.
>
> I'm pretty sure that methods must return string and that's the only
> requirement on them.
>
> That basically means you can use template engines directly. If it is mako
> something like that should work:
>
> from mako.template import Template
> print Template("hello ${data}!").render(data="world")
>
> Example was shamelessly take from first page of
> http://www.makotemplates.org/.

Yes, the biggest issue is whether the template engine accepts input
from a string.  I didn't realize Mako did.  I had to consider this
when I was building that upgrade to Buffet that didn't end up being
used.  My research showed that some engines have flexible input
formats, while others are more narrow.

render_mako() should really be considered a convenience function.  It
encapsulates some repetitive steps, and that's it's only purpose.
It's not intended to enforce some API that you have to use.  It's just
that the render_* functions shipped with Pylons have to use a common
API to avoid confusing newbies.  The most commonly-requested change is
to pass a dict of template values rather than using 'c'.  You can
certainly do that (although I personally like 'c' better).

-- 
Mike Orr <[email protected]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to