Home Login Create account Contact Help
Close

Login to your account

Other Options

Comments feed

In response to XML or Text for Python Templates?

There are a number of (very good) templating systems and languages available for Python. They fall in to one of two camps; either they are XML based, like Genshi, or they are text based, like Mako. Most programmers favour one or the other, but there is far from a consensus over which is better.

I'd like to use this debate to gather reasons for using one over the other in the context of web development. I suspect there will be no clear winner, but it should serve as a useful resource for those faced with the decision!

...

NB. You can post code with the [code] bbcode tag. Many languages are supported. e.g.

[code python]

print "Hello, World!"

[/code] 

metapundit argues for "XML"
Mon, 15 Oct 2007 by metapundit
Rank 2. Average +1.0 ( 5 votes )
The ability to preview templates directly in a browser shouldn't be minimised!

The biggest advantage of XML based templates is previewability (to coin a new word). In a typical XML based template system I can create an entire HTML page (head section and all) with relative links to related javscript, CSS, and image resources. I can insert dummy content into nodes in the document like

<h1 template:replace="title">This will be the Headline</h1>

<h1 template:replace="title">This will be the Headline</h1>

and preview the whole thing in a browser without even involving a webserver. Specify a rewrite path or two and the same template will be transformed to point paths to the right server locations - you can seamlessly switch between viewing static files locally and deploying templates remotely. The ability to preview templates directly in a browser shouldn't be minimised!

Return to debate