Sunday, February 04, 2007

Cheetah base templates

You can define a base class:

class base:
def __init__(self):
web._compiletemplate('default.html', base='base')

Use it:

class page1(base):
def GET(self):
web.render('page1.html')


Your templates:

#DEFAULT.HTML
< html >

< body >
#block content
CONTENT
#end block
< / body >
< / html >

#PAGE1.HTML
#extends base

#def content

PAGE 1


You're on the 1st page.
#end def

#PAGE2.HTML
#extends base

#def content

PAGE 2


You're on the 2nd page.
#end def

No comments: