Hi, Anand
Thanks your help. it works. but it seem that the "lstrips" should be
"rstrips". :)

further more, I also found that below code can work as well, but it
was very strange that when I put the render result to the other
template, it will always stay on the top of the output html page.

here is the code:

maincontent = web.render(selected_file)
print render.layout(header, sidemenu, maincontent)

and here is teh layout.html template:

$def with (header, sidemenu, maincontent)

<html>
<body>
<div id="head"> $: header </div>
<div id="sidemenu"> $: sidemenu</div>
<div id="maincontent">$: maincontent</div>

</body></html>

As my thought, the "maincontent" which rendered by
"web.render(selected_file)" should be placed after "header" &
"sidemenu", but in fact, the "maincontent" always be placed at the top
of the html page. like this:

--------------- html output ------------------
<h1>this is title</h1>
......
<html>
....
<body>
<div id="head"> .--here is the output of 'header'</div>
...
</body></html>
-----------------------------------------------

Do you have any idea on this?

regards


On 6月5日, 下午1时38分, "Anand Chitipothu" <[EMAIL PROTECTED]> wrote:
> 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