>
> 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.

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))



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to