parent
c210650ca7
commit
84a34c89e7
7 changed files with 57 additions and 3 deletions
@ -0,0 +1,15 @@ |
||||
breadcrumbs = {} |
||||
|
||||
|
||||
def add(route, label, parent=None): |
||||
breadcrumbs[route] = {'label': label, 'route': route, 'parent': parent} |
||||
|
||||
|
||||
def find(route): |
||||
crumbs = [] |
||||
while route: |
||||
crumb = breadcrumbs[route] |
||||
crumbs.append(crumb) |
||||
route = crumb['parent'] |
||||
crumbs.reverse() |
||||
return crumbs |
@ -0,0 +1,14 @@ |
||||
{% if crumbs %} |
||||
<nav class="breadcrumbs" aria-label="breadcrumb" role="navigation"> |
||||
<ol class="breadcrumb"> |
||||
{% for crumb in crumbs %} |
||||
<li class="breadcrumb-item"> |
||||
<a href="{% url crumb.route %}">{{ crumb.label }}</a> |
||||
</li> |
||||
{% endfor %} |
||||
<li class="breadcrumb-item active" aria-current="page"> |
||||
{{ current.label }} |
||||
</li> |
||||
</ol> |
||||
</nav> |
||||
{% endif %} |
Loading…
Reference in new issue