Templating engine?

Graham Dumpleton grahamd at dscpl.com.au
Mon Jun 21 00:52:19 EDT 2004


Paramjit Oberoi <p_s_oberoi at hotmail.com> wrote in message news:<pan.2004.06.20.20.22.40.152933 at hotmail.com>...
> > FWIW, I've designed, written, used and killed both types of systems,
> > and think the DOM-style beats macro-style hands down for the majority
> > of use-cases, and definitely the most graphic designer-friendly
> > approach. Suffice to say I've no plans for killing HTMLTemplate any
> > time soon. ;)
> 
> I expect it depends on what is changing more.  If you are working on code
> in the application, then you want the templates themselves to have no
> code.  On the other hand, if you are using a "finished" application and
> want to make changes to the HTML produced without fiddling with the
> application code, Cheetah-like systems are much more flexible (and simple
> substitution-only templates are very limiting).

Whether a Cheetah-like system is more flexible or not in comparison to a
DOM like system will depend on how the DOM system is implemented. If
the DOM system is strict in the sense that all access to elements is via the
hierarchy of HTML elements then yes Cheetah may be better, as any change
in the HTML structure will invalidate the associated code in a DOM type
system.

If however, the system which utilises a DOM structure uses node ids
to identify the important structural HTML elements where data is being
inserted, then the DOM system can still be somewhat better. This is because
the HTML element where data is being inserted would be accessed by the
node id, which would be cached in a lookup table at the time the HTML code
is parsed, thereby providing quick and direct access.

Thus, provided the DOM system uses ids and a lookup table which maps
that back to the actual HTML element hierarchy, the HTML page designer
can change the look of the code as much as they like, as long as they
retain the name id for the node where the data goes. This done, the code
which fills out the data doesn't have to change at all and the coder can
sleep easy knowing that a separate web designer is less like to screw it
all up.



More information about the Python-list mailing list