####### Heading ####### The "heading" template tag library provides 1 template tag: * headingcontext: helps you manage heading levels in HTML code. Requires a {% endheadingcontext %} closing tag. ************** headingcontext ************** With cascading templates, includes and bases, some parts of template code could be reused in different heading contexts. As an example, consider the following "home page" code in home.html: .. code-block:: html
... links to news ...
And consider the following "news page" code in news.html .. code-block:: html... links to news ...
You cannot reuse (include) news.html code into home.html, because the heading level does not match. The "headingcontext" template tag allows you to solve this problem. Here is modified home.html: .. code-block:: django {% load heading %}... links to news ...
You can use the additional "source_level" parameter in home.html: .. code-block:: django {% load heading %}... links to news ...
{% load heading %} {% headingcontext source_level=3 target_level=6 %} {% include "another_template_fragment_which_contains_some_h3.html" %} {% endheadingcontext %} Notice the use of the additional "target_level" parameter, which forces ouput levels to start at 6. You can read the provided test cases to observe what does this template tag at tests.HeadingContextTemplateTagTestCase.