PSP, Cheetah, PTL, ZOPE, etc ...

Andrew Kuchling akuchlin at mems-exchange.org
Wed Aug 1 14:54:17 EDT 2001


ChuckEsterbrook at yahoo.com (Chuck Esterbrook) writes:
> The *ML camp uses XML or XML-like tags for all instructions and
> substitutions. These include ZPT, Ehydra and others. There is a *ML
> like kit for Webware, but I don't think any serious time was put into
> it, hence it is hard to recommend (for Webware).

I've become quite fond of PTL's Python-based syntax.  Here's an
explanation of why (quoting from a not-yet-public article):

        This syntax is quite different from most HTML templating
        languages, which usually look like HTML with magical
        delimiters (e.g. <%...%>, <?...?>, <!--#... -->) sprinkled
        throughout. After we'd been using the Python-inspired PTL
        syntax for a while and found we quite liked it, Neil
        Schemenauer came up with an explanation for why it works so
        well. Most templating languages assume the content is mostly
        HTML with just a few small bits of program code here and
        there. The presence of program code is therefore signalled by
        some escape sequence from normal HTML, <%...%> or
        whatever. This works nicely if the amount of HTML really does
        dominate the amount of program code. But... if you're
        following good software design principles, as you develop the
        interface you factor out repeated chunks into functions. For
        example, instead of coding 10 rows of a table as HTML, you'll
        write a loop that repeats a single row 10 times. If you follow
        this principle, the amount of HTML code continually shrinks,
        replaced by invocations of various functions and templates,
        until the density of the escape sequence in the source code is
        unreadably high.

        Without its authors ever realizing this while designing it,
        PTL turns the idea of HTML templating on its head: the default
        is program code, and there's an escape sequence into HTML,
        namely Python's notation for string literals, which is compact
        and easily readable. Functions that actually contain HTML
        therefore can look a little messy, but that's only in the
        lowest-level functions; the bulk of our PTL code simply calls
        other PTL templates.

Of course, we don't care about people using graphical HTML editors;
that would be impossible to accommodate with PTL.

--amk



More information about the Python-list mailing list