Simon Willison’s Weblog

Subscribe
Atom feed for templating

6 items tagged “templating”

2009

Django snippets: Smart {% if %} template tag. Chris Beaven's drop-in replacement for Django's {% if %} tag that adds comparison operators (less than, greater than, not equal etc) while staying backwards compatible with the less able original. I love it. This is one place where I no longer favour Django's stated philosophy: I think it's perfectly reasonable to use comparisons in presentation logic, and I've found that in my own code the lack of an advanced if tag frequently leads to pure presentation logic sneaking in to my view functions.

# 3rd March 2009, 3:03 pm / django, python, templating, if, chris-beaven

2008

Django snippets: “for” template tag with support for “else” if array is empty. A neat solution to a common pattern; I’d personally like to see this included in Django proper.

# 16th January 2008, 9:42 pm / django, python, templating, django-snippets

2007

Django Changeset 6671. Malcolm Tredinnick: “Implemented auto-escaping of variable output in templates”. Fantastic—Django now has protection against accidental XSS holes, turned on by default.

# 14th November 2007, 5:05 pm / malcolmtredinnick, django, autoescaping, xss, security, python, templating

Guardian Unlimited’s new look: Some background on templating. Nik Silver describes some of the challenges involved in building a complex new homepage using CSS and Velocity.

# 10th May 2007, 12:26 pm / niksilver, css, velocity, templating, guardianunlimite

Most HTML templating languages are written incorrectly. “If you ever find yourself in the position of designing an html template language, please make the default behavior when including variables be to HTML-escape them.” I couldn’t agree more.

# 15th April 2007, 8:28 pm / xss, security, templating, daniel-martin

2004

Backporting from Python 2.3 to Python 2.2

We have a home-grown templating system at work, which I intend to dedicate an entry to some time in the future. We originally wrote it in Python 2.2, but upgraded to Python 2.3 a while ago and have since been evolving our code in that environment. Today I found a need to load the most recent version of our templating system on to a small, long neglected application that had been running the original version ever since it had enough features to be usable.

[... 356 words]