not quite minimalistic enough  

Weltschmerz

Currently converting a Django project that was using ZPT via Chameleon to Django’s own template language.

No, I don’t think this is a good idea.

Unfortunately, Django’s developers make it increasingly difficult to generate XHTML, and recent versions have essentially made it impossible without rewriting a good bit of the framework itself.

For some reason, the Django project has decided to embark upon a crusade against XHTML, and my poor little ZPTs are its victims.

Honestly now. Which is better?

This:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal">
...
<body>
<h1 tal:content="section"/>
<p tal:repeat="item items" tal:content="item.label"/>
...

Or this:

<!DOCTYPE html>
<html>
...
<body>
<h1>{{ section }}</h1>
{% for item in items %}
<p>{{i item.label }}</p>
{% endfor %}
...

When done adequately, ZPT are well-formed XML. When done correctly, they are valid XHTML (the templates themselves, not just [but also!] their output).

Django templates, on the other hand, are line noise when done completely wrong, and still line noise when done “right”.

Written on October 4, 2018