Hi
What is the correct way to use another templating system from within
web.py. My first attempt results in correctly generated mako output
wrapped in <pre> tags.
How should I be calling the mako template?
--- code.py ---
import web
urls = (
'/(.*)', 'hello'
)
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)
class hello:
def GET(self, name):
i = web.input(times=1)
if not name:
name = 'world'
serve_template('hello.html', name=name, times=int(i.times))
if __name__ == "__main__":
web.run(urls, globals())
---
--- templates/hello.html ---
<ol>
% for n in range(times):
<li> ${n} ${name} </li>
% endfor
</ol>
----
Thanks,
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
-~----------~----~----~----~------~----~------~--~---