Changeset View
Changeset View
Standalone View
Standalone View
films/templatetags/film_extras.py
| from django import template | from django import template | ||||
| from common import markdown | |||||
| register = template.Library() | register = template.Library() | ||||
| @register.inclusion_tag('films/components/breadcrumbs.html', takes_context=True) | @register.inclusion_tag('films/components/breadcrumbs.html', takes_context=True) | ||||
| def show_breadcrumbs(context): | def show_breadcrumbs(context): | ||||
| """ | """ | ||||
| Creates a breadcrumb navigation for :template:`films/gallery.html` and | Creates a breadcrumb navigation for :template:`films/gallery.html` and | ||||
| :template:`films/collection_detail.html`. | :template:`films/collection_detail.html`. | ||||
| Show All 18 Lines | if collection: | ||||
| breadcrumbs.append((film.title, film.url)) | breadcrumbs.append((film.title, film.url)) | ||||
| else: | else: | ||||
| current_location = film.title | current_location = film.title | ||||
| return { | return { | ||||
| 'breadcrumbs': breadcrumbs[::-1], | 'breadcrumbs': breadcrumbs[::-1], | ||||
| 'current_location': current_location, | 'current_location': current_location, | ||||
| } | } | ||||
| @register.filter() | |||||
| def markdown_to_html(content): | |||||
| """Renders the markdown-formatted content as html, safely.""" | |||||
| result = markdown.render(content) | |||||
| return result | |||||