[ANN] HTMLTemplate 1.0.0

has has.temp2 at virgin.net
Wed Jun 2 14:49:38 EDT 2004


Duncan Booth <me at privacy.net> wrote in message news:<Xns94FC7930CEC00duncanrcpcouk at 127.0.0.1>...

> By contrast, a template in HTMLTemplate isn't valid HTML since it contains 
> undefined attributes in the default namespace. It is reasonable to expect 
> that an HTML editor will strip out the illegal attributes.

HTMLTemplate allows you to specify a different 'special' attribute
name via the Template constructor, so you can use attributes like 'id'
and XML namespaces instead of 'node' if you prefer. (The reason I made
'node' the default is that it's more or less self-explanatory so
convenient for new users. I've updated the HTMLTemplate homepage to
clarify this issue.)

It's also quite intelligent in how it parses these attributes. For
example, when using 'id', an element like <div id="con:foo">...</div>
would be identified as containing a legal compiler directive, the
special attribute stripped and a template node created. All other 'id'
attributes would be left untouched, however, so you can still safely
use them as normal id attributes on non-node elements.


> The ultimate Python templating framework for separating Python from the 
> template has to be PyMeld. PyMeld templates are pure XHTML with no 
> additional attributes whatsoever.

I looked at PyMeld early on as it's closest to HTMLTemplate in concept
and behaviour and about the same in code size and complexity. Its
shortcomings are a non-standard licence, an inferior API [compared to
HTMLTemplate] that requires users to write their own loops and,
according to its author, some performance issues due to naive
implementation. All quite fixable, of course, but it was just more
convenient for me to port my existing HTMLTemplate implementation to
Python.


Hope that allays your fears. :)

--

(p.s. Inquisitive users may also spot the potential for
meta-templating that being able to specify one's own 'special'
attribute names provides. Though whether anyone can come up with an
actual use for meta-templating is another question entirely...;)



More information about the Python-list mailing list