Prettify HTML5 middleware
Slightly updated version of http://djangosnippets.org/snippets/172/ . Supports new HTML5 tags (even though tidy doesn't).
- middleware
- tidy
- standard
- html5
Slightly updated version of http://djangosnippets.org/snippets/172/ . Supports new HTML5 tags (even though tidy doesn't).
This is an enhancement of snippet [#172](http://djangosnippets.org/snippets/172/). Here I use [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/) — far more easier to install through pip in a virtualenv, and possibly a bit more maintained — to format and properly indent the rendered HTML from templates. I also added a check to only tidy contents in a `DEBUG=True` environment, regarding high impact on performance while doing so in production. Last, it's compatible with Django 1.2.x.
Development middleware to ensure that responses validate as HTML.
with this middleware you can use tidy to prettify your html, just add the class to the `MIDDLEWARE_CLASSES` setting. tidy has an enormous number of options, se [Tidy Options Reference](http://tidy.sourceforge.net/docs/quickref.html) . you must have [µTidylib](http://utidylib.berlios.de/) installed.
4 snippets posted so far.