Templating engine?

has has.temp2 at virgin.net
Mon Jun 21 11:14:24 CEST 2004

Paramjit Oberoi <p_s_oberoi at hotmail.com> wrote in message news:<pan.2004. 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. 
> 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, 

Presentation logic is application code too, regardless of where you
put it and what language it's written in.

- The advantage of embedding logic in markup is it's easier for
non-programmers and other folk who aren't good at/don't like working
in the abstract to see what's going on. (i.e. easier mental modelling)

- The advantage of separating the two is very designer-friendly markup
and complete freedom in how you design and implement the logic. (i.e.
easier maintainance)

With HTMLTemplate et-al, there's nothing to stop you putting the
controller code in separate modules to the model code, making it easy
to edit the former without messing with the latter. (Splitting each
layer into its own module is probably a good design practice anyway.)

> Cheetah-like systems are much more flexible (and simple
> substitution-only templates are very limiting).

DOM-style templating systems aren't 'substitution-only', and can
easily match or surpass macro-style systems for power and flexibility
at a fraction of the size and complexity.

More information about the Python-list mailing list