Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Jinja2 Final aka Jinjavitus Released. The Jinja template engine now has auto-escaping as an optional feature, disabled by default. Worth considering as an almost drop-in replacement for Django’s template language if features such as macros and compilation to Python code appeal to you.

Tagged , , ,

2 comments

  1. So, it's an HTML templating system that's guaranteed to produce invalid HTML <em>by default</em>. Genius, kids.

    Seriously, auto-escaping defaulting to off is the wrong default.

    Dominic Mitchell - 21st July 2008 07:39 - #

  2. It's really not guaranteed to produce invalid HTML at all.

    If you have a piece of data that needs to be escaped, you can request it specifically for *that* individual piece of data. No need to waste resources escaping data that's already been escaped.

    It's a trade-off of speed versus ease of use and guaranteed coverage. Plus auto-escape will sometimes double-escape AND the templating engine may be used for things other than HTML (we use it for text e-mail and PostScript generation)

    Ben - 21st July 2008 23:29 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site