This project is a packaging of Paul Irish's HTML5 Boilerplate for Django projects. It contains a base template, the required media, and—most importantly—a collection of template tags so you can easily integrate all of the boilerplate's tricks into your pages if the template starts to feel too restrictive.
The bundled media and templates correspond to the 1.0 release of HTML5 Boilerplate.
Add html5boilerplate
to INSTALLED_APPS
in settings.py. If you plan to
make use of the included media (bundled JavaScript and CSS files), either copy
the media folder to your project or duplicate whatever setup you're using for
your admin media files (collectstatic, symlink, server alias, etc.)
You can either extend the included template ("html5boilerplate/base.html"), or
create your own using the included template tags, which can be loaded using
{% load html5boilerplate_tags %}
. Here is a list of the included tags:
- google_analytics
- Embeds the GA tracking script. You can either pass it your tracking code, or set `GA_TRACKING_CODE` in settings.py
- tagvariants
- Creates duplicates of the wrapped opening tag, each wrapped in an IE
conditional comment, with an added class identifying the version of IE.
For example:
would result in the following:
{% tagvariants %}<html lang="en" class="whatever">{% endtagvariants%}
<!--[if lt IE 7 ]><html lang="en" class="ie6 whatever"><![endif]--> <!--[if IE 7 ]><html lang="en" class="ie7 whatever"><![endif]--> <!--[if IE 8 ]><html lang="en" class="ie8 whatever"><![endif]--> <!--[if (gte IE 9)|!(IE)]><!--><html lang="en" class="whatever"><!--<![endif]-->
This would usually be used on the `<html>` tag, and allows you to easily target versions of your favorite browser. </dd> <dt>load_jquery</dt> <dd>Loads jQuery by trying each item in a list of sources until one is successful. By default, this tag will first try to load the library from Google's CDN and then—if it fails—will load the bundled copy. However, you can override this behavior by either passing a list of sources to the tag or setting `JQUERY_SOURCES` in settings.py. </dd>
This application supports the following settings:
- GA_TRACKING_CODE
- A default tracking code to use for the `google_analytics` template tag. If this is set, you can use the template tag without arguments.
- JQUERY_SOURCES
- A list of sources that jQuery can be found at, in the order in which they should be tried. If this is set, you can use the `load_query` tag without arguments.
- HTML5_BOILERPLATE_STATIC_PREFIX
- A prefix to be used for the bundled media urls. By default, the template will use "/static/html5boilerplate/".