CherryPy Project Download

Using HTMLTemplate with CherryPy

HTMLTemplate can be downloaded here


<title node="con:pagetitle">Test title</title>
<p node="con:myquote">Test quote</p>

import cherrypy
from HTMLTemplate import Template
class Begin:
    def renderTemplate(self, node, title, quote):
        node.pagetitle.content = title
        node.myquote.content = quote
    def index(self):
        html = file("test.html").read()
        template = Template(self.renderTemplate, html)
        return template.render('Quote of the Day', 'God does not play dice.')

Older versions

replace this with this
2.2cherrypy.quickstart(Begin())cherrypy.root = Begin()
2.0import cherrypyfrom cherrypy import cpg as cherrypy

Hosted by WebFaction

Log in as guest/cherrypy to create/edit wiki pages