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] 



Martijn Faassen argues for "Text"
Mon, 15 Oct 2007 by faassen
Rank 5. Average +0.2 ( 4 votes )

Python is text with a grammar. XML is also text with a grammar. Both have rules. The inevitable output for a web page is HTML. This is a third grammar, related to XML but more liberal.

If you believe that templates need to contain a significant amount of Python code, mixing these grammars become harder to understand. Rather mix two grammars (Python and HTML) in a single template than three.

Anthony Briggs comments...
Wed, 17 Oct 2007 by anthony
I'd disagree here, mainly on the "templates need to contain a significant amount of Python code" part. If you've got a lot of code in your template, you're doing it wrong!

Also, XML and HTML are semantically fairly similar, so I'm not sure that side of it holds either.
Martijn Faassen comments...
Sun, 28 Oct 2007 by faassen
According to Anthony Briggs:

If you've got a lot of code in your template, you're doing it wrong!


That's why I said "if you believe that templates need to contain a significant amount of Python code". I don't necessarily agree that this should be the case myself. :)



Return to debate