|
|
@ -1,4 +1,4 @@ |
|
|
|
from os.path import dirname |
|
|
|
import os |
|
|
|
|
|
|
|
import yaml |
|
|
|
from django import template |
|
|
@ -10,10 +10,13 @@ TEMPLATES_DIR = BASE_DIR.child("templates") |
|
|
|
|
|
|
|
|
|
|
|
@register.inclusion_tag('menus/subnav.html', takes_context=True) |
|
|
|
def subnav(context, path): |
|
|
|
yaml_filename = TEMPLATES_DIR.child(*path.split('/')) |
|
|
|
def subnav(context, path=None): |
|
|
|
obj = context['object'] |
|
|
|
if not path: |
|
|
|
path = '%s/subnav.yaml' % obj.__class__._meta.app_label |
|
|
|
yaml_filename = os.path.join(TEMPLATES_DIR, path) |
|
|
|
menu = yaml.load(open(yaml_filename, 'r')) |
|
|
|
resolve_urls_inplace(menu, context['object'].pk) |
|
|
|
resolve_urls_inplace(menu, obj.pk) |
|
|
|
return dict(menu=menu) |
|
|
|
|
|
|
|
|
|
|
|