[Web-SIG] DOM-based templating

Phillip J. Eby pje at telecommunity.com
Fri Jun 3 18:40:23 CEST 2005


At 12:20 PM 6/3/2005 -0400, James Y Knight wrote:
>Just inserting all the whitespace from the original document into the
>DOM is a pretty safe thing to do, but it'd be nice to not have to do
>that, as you end up with excessive numbers of text nodes that have no
>meaning.

PWT (peak.web.templates) deals with this by concatenating all non-dynamic 
nodes into a single "literal" (i.e. unescaped) text node.

PWT also isn't anything like a traditional DOM, in that it's a hierarchical 
structure, but that structure need not resemble the document structure in 
any way.  So, if you guys manage to come up with a decent HTML parser, I'll 
be interested in gluing it to PWT, as long as it can deal with XML 
namespaces.  PWT trees are currently constructed with expat, but the actual 
template components don't know anything about parsing and don't care.

(Another difference between PWT and other DOM-based templating systems is 
that in PWT, a component is more like a function than a data 
structure.  Instead of code receiving DOM data structures, they receive the 
moral equivalent of function parameters; so they can invoke them and pass 
parameters in, but they can't directly manipulate the DOM structure, 
because it's not a DOM structure.  So, the Python code parts are largely 
immune to presentational concerns; they can't even *see* the content of the 
HTML they're manipulating.)



More information about the Web-SIG mailing list