DRY menu Custom Template Tag
This is the description of a custom template tag to create DRY menu. It solves the problem of markup duplication in templates of your site. The menu always has one active option and one or several inactive options. HOW TO USE Define a structure of your menu in a parent template: {% defmenu "menu1" %} {% active %}<span class='active'>__text__</span>{% endactive %} {% inactive %}<a href='__url__'>__text__</a>{% endinactive %} {% opt "opt1" "/opt1/" %}Go to opt1{% endopt %} {% opt "opt2" "/opt2/" %}Go to opt2{% endopt %} {% opt "opt3" "/opt3/" %}Go to opt3{% endopt %} {% enddefmenu %} The menu has it's name (first parameter of the tag 'defmenu'. First parameter of a tag 'opt' is menu option's name. '__text__' inside of 'active'/'inactive' will be substituted by inner text of a tag 'opt' (Go to opt...), '__url__' indide of 'active'/'inactive' will be substituted by second parameter of a tag 'opt' To generate menu with one selected option in child template do: {% menu "menu1" "opt1" %} Here: "menu1" is a name of menu that was defined by 'defmenu' tag, "opt1" is selected option. Result of the applying 'menu' is the next: <span class='active'> Go to opt1</span> <a href='"/opt2/"'>Go to opt2</a> <a href='"/opt3/"'>Go to opt3</a>
- menu
- dry
- menubar