oioioi.base.templatetags.menu
¶
Module Contents¶
Classes¶
Functions¶
|
A template tag which produces the menu. |
Attributes¶
- oioioi.base.templatetags.menu.generate_menu(parser, token)[source]¶
A template tag which produces the menu.
Adds a
menu
key to the template context, which is a list of dictionaries, each represnting a single menu item. Each of them has two keys:name
,text
andurl
.Usage with default menu registry (
oioioi.base.menu.menu_registry
):{% load menu %} {% generate_menu %} {% for item in menu %} <li> <a href="{{ item.url }}" {{ item.attrs }}>{{ item.text }}</a> </li> {% endfor %}
Usage with non-default menu registry:
{% load menu %} {% generate_menu 'oioioi.base.admin.admin_menu_registry' %} {% for item in menu %} <li> <a href="{{ item.url }}" {{ item.attrs }}>{{ item.text }}</a> </li> {% endfor %}
It’s also possible to pass a variable containing an instance of
MenuRegistry
as an argument.