Using page templates
The only thing missing at this point is templates. But of course, they are there as the Nevow templating. enamel.pages.template is analogous to nevow.loaders.xmlfile
However using a template is quite simple in basic use. The document method of any page returns the value of self.docFactory as with Nevow.
A template must be an XML document as follows
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" xmlns:n="http://nevow.com/ns/nevow/0.1">
<head>
<title>Example</title>
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
</head>
<body>
<div n:render="body"/>
</body>
</html>
The page is then created as
class TemplatedPage(pages.Standard): def document(self): return pages.template('mytemplate.xml', templateDir='./templates') def body(self): return tags.div[ "Some contents" ]
You'll note somehow the body was added to the div. This is because there is actually another method behind body(), that is a render method.
Render methods are called with n:render to fill the tag they are attached to, and defined quite simply as follows
class TemplatedPage(pages.Standard): def document(self): return pages.template('mytemplate.xml', templateDir='./templates') def render_froober(self, ctx, data): return ctx.tag(tags.div["Some contents"])
This is with "<div n:render="froober"/>" being somewhere in the body of course. It need not be a div tag, any tag can be rendered over.
The Nevow templates go much further afield than this, fortunately there is very good documentation here http://divmod.org/trac/browser/trunk/Nevow/doc/txt/nevow-xml-templates.txt
Other pages
Other templating procedures are documented in other sections such as SQL and Athena
