about template: how to easy do include header.html or foot.html?

4 views
Skip to first unread message

大郎

unread,
Oct 7, 2007, 11:13:00 AM10/7/07
to we...@googlegroups.com
in my test project code, i write like this:

code.py
class index:
    def GET(self):
        todos = web.select('todo')
        # print render.error(list(todos))
        # return False
        print render.index(todos, header=render.header(), foot=render.foot())

every class i will write render.header() and render.foot(), it is truble..and the header.html and foot.html are public.
do it has a easy way to bulid it?
eg: in template file can be wrote like: include foot.html...

index.html
$def with (todos, header, foot)
$:header
        <ul>
            $for todo in todos:
                <li id="t$todo.id"><span title="$todo.created">$todo.title</span> &nbsp; <a href="/item/$todo.id/edit">edit</a> <a href="/drop?id=$todo.id">x</a></li>
        </ul>

        <form action="add" method="post">
            <p>Add a new item: </p>
            <p>
            <input type="text" name="title" />
            <input type="submit" value="Add" />
            </p>
        </form>
$:foot

--
每个人都有一片属于自己的森林, 迷失的人迷失了, 相逢的还会再相逢...
Gtalk: iexper(at)gmail.com

bubblboy

unread,
Oct 7, 2007, 6:34:32 PM10/7/07
to we...@googlegroups.com

Ken

unread,
Oct 7, 2007, 8:53:58 PM10/7/07
to we...@googlegroups.com
ashok raavi (http://mysite.picsquare.com/) told me a new style to bulid it:
# code.py
...
web.template.Template.globals['render'] = render

# index.html
...
$def with (todos)
$:render.header()
...
$:render.foot()

:)
Reply all
Reply to author
Forward
0 new messages