On 31/08/2007, Anand <[EMAIL PROTECTED]> wrote:
>
> > from mako.lookup import TemplateLookup
> > mylookup = TemplateLookup(directories=['templates/'],
> > module_directory='mako_modules')
> >
> > def serve_template(templatename, **kwargs):
> > mytemplate = mylookup.get_template(templatename)
> > print mytemplate.render(**kwargs)
>
>
> I think templator approach is the best.
I have no preferences as yet. Just in the process of converting a
web.py 0.1 app into a web.py 0.2 app and hit some snags with templator
-- probably just my own conditioning that needs to change ;-)
Do you reckon there'll be a performance hit associated with using a
third-party templating system?
> from mako.lookup import TemplateLookup
>
> class mako_render:
> def __init__(path):
> self._lookup = TemplateLookup(directories=[path],
> module_directory='mako_modules')
>
> def __getattr__(self, name):
> path = name + '.html'
> t = self._lookup.get_template(path)
> t.__call__ = t.render
> return t
>
> render = mako_render('templates/')
>
> class hello:
> def GET(self, name):
> i = web.input(times=1)
> if not name:
> name = 'world'
> print render.hello(name=name, times=int(i.times))
Thanks very much Anand, I'll give this a try.
Cheers,
Ryan
--
Ryan Tracey
Citizen: The World
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---