How do web templates separate content and logic?

George Sakkis george.sakkis at gmail.com
Mon Jun 30 13:41:17 EDT 2008


On Jun 30, 1:19 pm, Mike <ter... at gmail.com> wrote:
> On Jun 30, 10:57 am, Bruno Desthuilliers <bruno.
>
> 42.desthuilli... at websiteburo.invalid> wrote:
>
> > Some (if not most) templating systems use their own mini-language to
> > handle presentation logic.
>
> IMHO this is the funniest (worst) part of all this 'templating'
> buss  :)
> It reminds me the good old slogan: "Have you invented your own GUI
> library yet?"
>
>
>
> > The meme "thou shall not mix domain logic with presentation" is very
> > often misunderstood as "you must not have anything else than html in
> > templates", which is just plain non-sense. Even declarative templating
> > systems (cf Has's post) require some special (ie: non standard) stuff to
> > work.
>
> > > Or could it just be that
> > > this is a *good* way to mix HTML and Python, and there are other ways
> > > which may be bad?
>
> > Bingo.
>
> Then what is so *good* about it, why embedding HTML into Python is not
> good?

Because _typically_ a web template consists of mostly HTML, with
relatively little presentational logic and (ideally) no business
logic. Now, if all one wants to do is a quick and dirty way to, say,
view a log file in the browser, a separate template is probably an
overkill; there's nothing wrong with something like "for line in
logfile: print cgi.escape(line.strip()) + '<BR>'". It's a matter of
relative frequencies which language is the embedded one.

George



More information about the Python-list mailing list