Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
flatten context before rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Oct 6, 2016
1 parent 6ff5563 commit f2e6b17
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,19 @@ def render_breadcrumbs(context, *args):

if not links:
return ''
context['breadcrumbs'] = links
context['breadcrumbs_total'] = len(links)
return mark_safe(template.loader.render_to_string(
template_path, context))

try:
ctx = context.flatten()
except AttributeError:
# fallback for older (< 1.7) django without flatten()
ctx = {}
for d in context.dicts:
ctx.update(d)

ctx['breadcrumbs'] = links
ctx['breadcrumbs_total'] = len(links)

return mark_safe(template.loader.render_to_string(template_path, ctx))


class BreadcrumbNode(template.Node):
Expand Down

0 comments on commit f2e6b17

Please sign in to comment.