|
@ -1,4 +1,4 @@ |
|
|
from os.path import dirname |
|
|
import os |
|
|
|
|
|
|
|
|
import yaml |
|
|
import yaml |
|
|
from django import template |
|
|
from django import template |
|
@ -10,10 +10,13 @@ TEMPLATES_DIR = BASE_DIR.child("templates") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.inclusion_tag('menus/subnav.html', takes_context=True) |
|
|
@register.inclusion_tag('menus/subnav.html', takes_context=True) |
|
|
def subnav(context, path): |
|
|
def subnav(context, path=None): |
|
|
yaml_filename = TEMPLATES_DIR.child(*path.split('/')) |
|
|
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')) |
|
|
menu = yaml.load(open(yaml_filename, 'r')) |
|
|
resolve_urls_inplace(menu, context['object'].pk) |
|
|
resolve_urls_inplace(menu, obj.pk) |
|
|
return dict(menu=menu) |
|
|
return dict(menu=menu) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|