:tocdepth: 2
.. |webcore| replace:: Webcore
.. _templates:
Templates
=========
Webcore provide some useful reusable generic templates. Most of them only needs to be styled with CSS, others are
a good starting point to make your own.
HTML5boilerplate
----------------
For the moment this is the only base template available. This base template is a HTML5boilerplate template which contains (hopefully) all the necessary blocks to be extended.
First it's important to understand the blocks name spacing. The three most important namespaces are *site*, *project*, *app*.
Here's an hierarchical map of the block namespaces::
- site: generic stuff
- project: project global stuff
- app: application specific stuff
Extending base
^^^^^^^^^^^^^^
The application templates should extend a base.html template that sits at project level. For portability convenience it should not extends the base.html provided by webcore directly.
For example, you project's base.html could look like this::
{% extends "html5boilerplate/base.html" %}
{% block project.headstyles %}
{% endblock%}
{% block project.title %}webcore{% endblock %}
{% block project.head %}
{# It's strongly suggested to use content as main content block #}
{# since most reusable apps use this block. #}
{% block content %}{% endblock %}
{% block project.footer %}
{% block app.footer %}{% endblock %}
{% endblock %}
{% endblock %}
Site blocks
^^^^^^^^^^^
The site blocks are top level blocks that usually wraps project and app blocks. Those block serves as "defaults" that can be extended.
+------------------+-----------------------------------+
| Block | Description |
+==================+===================================+
| site.head | Wraps the content of `` |
+------------------+-----------------------------------+
| site.title | Wraps the `` element |
+------------------+-----------------------------------+
| site.meta | Wraps the description, keywords, |
| | project & app metas |
+------------------+-----------------------------------+
| site.headstyles | Wraps the project and app style |
| | blocks |
+------------------+-----------------------------------+
| site.headscripts | Wraps the project and app script |
| | blocks |
+------------------+-----------------------------------+
| site.body | Wraps the project head, body, |
| | footer blocks |
+------------------+-----------------------------------+
| site.styles | Wraps the project and app style |
| | blocks |
+------------------+-----------------------------------+
| site.scripts | Wraps the project and app script |
| | blocks. Also contains some other |
| | JS functionalities |
+------------------+-----------------------------------+
Project blocks
^^^^^^^^^^^^^^
The project blocks provide blocks that should be used at project level in django.
+-----------------------+----------------------------------------------+
| Block | Description |
+=======================+==============================================+
| project.title | Project title are appended after app title |
+-----------------------+----------------------------------------------+
| project.description | Project's description |
+-----------------------+----------------------------------------------+
| project.keywords | Project's keywords |
+-----------------------+----------------------------------------------+
| project.meta | Project title are appended before app meta |
+-----------------------+----------------------------------------------+
| project.favicon | Wraps the favicon element |
+-----------------------+----------------------------------------------+
| project.headstyles | Block to add styles to the head of document |
+-----------------------+----------------------------------------------+
| project.headscripts | Block to add scripts to the head of document |
+-----------------------+----------------------------------------------+
| project.head | Project's head |
+-----------------------+----------------------------------------------+
| project.body | Project's body |
+-----------------------+----------------------------------------------+
| project.footer | Project's footer |
+-----------------------+----------------------------------------------+
Other blocks
^^^^^^^^^^^^
Some other blocks are provided for more edgy use cases
+------------------+------------------------------------------------------+
| Block | Description |
+==================+======================================================+
| doctype | wraps the doctype, by default `` |
+------------------+------------------------------------------------------+
| html.class | You can add classes to the `` tag with this |
+------------------+------------------------------------------------------+
| html.extra | You can add attributes to the `` tag with this |
+------------------+------------------------------------------------------+
Pagination
----------
A generic pagination template. You can paginate any list views simply by including the template like this::
{% include "pagination.html" %}
This template outputs something like this::