On Thu, Jun 5, 2008 at 9:52 AM, flywood <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'd like to render a template that its name was submitted by user,
> like below code:
>
> class view:
>    def GET(self, selected_file):
>        if selected_file == 'template1.html':
>            print render.template1()
>        if selected_file == 'template2.html':
>            print render.template2()
>
> Any smarter way to handle this kind situation when there are many
> selected templates?

name = web.lstrips(selected_file, '.html')
print getattr(render, name)()

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