A simple Django navigation template tag
Project description
A simple Django template tag to handle navigation item selection.
Usage
Add the app to your INSTALLED_APPS setting:
INSTALLED_APPS = (
# ...
'django_navtag',
)
Give your base template a navigation block something like this:
{% load navtag %}
{% block nav %}
{% nav text ' class="selected"' %}
<ul class="nav">
<li{{ nav.home }}><a href="/">Home</a></li>
<li{{ nav.about }}><a href="/about/">About</a></li>
</ul>
{% endblock %}
In your templates, extend the base and set the navigation location:
{% extends "base.html" %}
{% block nav %}
{% nav "home" %}
{{ block.super }}
{% endblock %}
Using a different context variable
By default, this tag creates a nav context variable. To use an alternate context variable name, call {% nav [item] for [var_name] %}:
{% block nav %}
{% nav "home" for sidenav %}
{{ block.super }}
{% endblock %}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-navtag-3.0.tar.gz
(9.3 kB
view hashes)
Built Distribution
Close
Hashes for django_navtag-3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 981d577e471c83fb5ef984f9e2a28619c31c722d1f048d754d56bb386030c4e2 |
|
MD5 | 3ef99bd05000cba9e49ca9dc66de7377 |
|
BLAKE2b-256 | 82e1e7fbb0885396fc8ca2c5f048074be28bbc20aa1bae2e558f435489abdbd3 |