How do web templates separate content and logic?

has has.temp3 at virgin.net
Mon Jun 30 08:33:07 EDT 2008


On 29 Jun, 04:18, John Salerno <johnj... at gmailNOSPAM.com> wrote:

> No, I don't mean presentation logic at all. I mean something along the
> lines of combining HTML (which is what I refer to as "content") and
> Python (which is what I meant by "logic").

[Note: if you're not familiar with MVC, best go read up on it now
otherwise none of this thread'll makemuch  sense.]

As Bruno says, the goal of most templating engines is to separate the
business portion of your application from the user interface portion,
basically slicing along the existing Model/View divide in the commonly
used (Model-View-Controller (MVC) application design pattern.

However, if you want a finer-grained divide between HTML markup and
presentation logic within the View layer itself, there are a few
templating engines that support this: PyMeld, HTMLTemplate (mine),
Nevow. These keep the Python-based presentation logic completely
separate from the HTML-based presentation markup, relying on simple
tag attributes to identify HTML elements can be manipulated
programmatically.

The initial learning curve's a bit steeper for these engines due to
the higher level of abstraction, but once you get your head around the
overall concept they're quite simple to use since you don't have to
learn a separate mini-language, write Python code in an HTML editor,
or anything like that.

HTH

has



More information about the Python-list mailing list