Git Product home page Git Product logo

django-html5boilerplate's Introduction

django-html5boilerplate

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 2.0 release of HTML5 Boilerplate.

Installation

Add html5boilerplate to INSTALLED_APPS in settings.py. If you plan to make use of the included media (bundled JavaScript and CSS files), don't forget to run collectstatic (or copy the media folder if you're using an older version of Django (< 1.3)).

Usage

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 %}.

Template Tags

googleanalytics

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:

{% tagvariants %}<html lang="en" class="whatever">{% endtagvariants%}

would result in the following:

<!--[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 IE 9 ]><html lang="en" class="ie9 whatever"><![endif]-->
<!--[if (gt 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.

loadjquery

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 specify your own sources by setting JQUERY_SOURCES in settings.py.

loadjsuntil

A more generic version of loadjquery, useful for providing fallback sources for any library. Example:

{% loadjsuntil "jQuery.ui" %}
	<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js" type="text/javascript" charset="utf-8"></script>
	<script src="{{ STATIC_URL }}js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
{% endloadjsuntil %}

The tag accepts one argument, which specifies a window-level object whose existence indicates the library has been successfully loaded. The contents of the tag are script nodes that will be written to the DOM until the object exists.

Settings

This application supports the following settings:

GA_TRACKING_CODE
A default tracking code to use for the googleanalytics template tag. If this is set, you can use the template tag without arguments.
JQUERY_SOURCES
A list of sources that the `loadjquery` tag should use.
HTML5_BOILERPLATE_STATIC_PREFIX
A prefix to be used for the bundled static file urls. By default, the template will use "/static/html5boilerplate/".

django-html5boilerplate's People

Contributors

lettertwo avatar matthewwithanm avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.