The war over templating

I’m currently looking at Python templating systems, for various reasons. During my search, I came across the following exchange in a perl.com article called Choosing a Templating System, between fans of allowing your real language (in this case, Perl) to be inlined in the templates, and fans of having no “real” language in the templates and instead allowing a “mini-language” or just variable substitution:

IN-LINE: Mini-languages are stupid. I already know Perl and it’s easy enough. Why would you want to use something different?

MINI-LANG: Because my HTML coder doesn’t know Perl, and this is easier for him.

IN-LINE: Maybe he should learn some Perl. He’d get paid more.

MINI-LANG: Whatever. You just want to use in-line Perl so you can handle change requests by putting little hacks in the template instead of changing your modules. That’s sloppy coding.

IN-LINE: That’s efficient coding. I can knock out data editing screens in half the time it takes you, and then I can go back through, putting all the in-line code into modules and just have the templates call them.

MINI-LANG: You could, but you won’t.

IN-LINE: Is it chilly up there in that ivory tower?

MINI-LANG: Go write some VBScript, weenie.

I think that that covers the differences rather neatly. And I still can’t decide.

None

6 Responses to “The war over templating”

  1. I’m a huge fan of both PyMeld and Quixote PTL. I dislike inline code, but admit I haven’t developed a full-blown webapp (with session, logins, features customized per user) with something like PyMeld… so this view could change :)Anyway, in a project I’m just starting, I would like to provide flexibility for plugging in any Python templating system. I’ll make sure to have working PyMeld, Cheetah, and PTL examples in the distribution.

    Van Gale
  2. I was pretty sure that real code inlined in templates is the best way(especially for my own projects), but ZPT showed me that maybe it’s possible to design a templating system that’s powerful without embedding significant amounts of code. RoundUp uses it quite successfully outside of Zope, too, I believe.Of course, Python doesn’t really shine when inlining, the syntax does get in the way there.

    Juri Pakaste
  3. I’m currently looking into Cheetah template: http://www.cheetahtemplate.org/ you can use together with WebWare or separately as a vanilla template engine to generate HTML/XML/text. The syntax is terse and almost pythonic (except for that “end block” statements). With WebWare you also get PSP (Python Server Pages) the IN-LINE choice.

    deelan
  4. Maybe that guy would get paid more if he learned some Perl… or maybe he’s not getting paid at all, he’s using his off time to try and use your code for something, and you’re wasting his time.How many people do you want to drive away from your code?Anyway, why not provide both choices?

    misuba
  5. If it’s templating for HTML/XML, then a third approach is to have the template externally transformed by a real language, the parts to be manipulated being identified by id attributes. This is the approach exemplified by PyMeld (http://www.entrian.com/PyMeld/).

    Hamish Lawson
  6. And yet one more way: your markup *is* code (or vice-versa I suppose).

    http://breve.twisty-industries.com/

    [disclaimer: blatant self-promotion]

    Cliff Wells

Leave a Reply

OpenID is a decentralised authentication system. If you use LiveJournal or Vox you already have an OpenID; just use the URL of your homepage there. See also how to get yourself an OpenID.