1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from django import template
register = template.Library()
@register.filter
def render_markup(string, markup_lang=None):
from django.contrib.markup.templatetags import markup
if markup_lang:
markup_lang = markup_lang.lower()
try:
return getattr(markup, markup_lang)(string)
except AttributeError:
raise ValueError("Markup filter %r not found." % markup_lang)
return string
|
More like this
- i18n base model for translatable content by foxbunny 3 years, 10 months ago
- Analogue template filter to removetags that also removes the content of the tag by piquadrat 1 year, 6 months ago
- Tags & filters for rendering search results by exogen 4 years, 2 months ago
- MarkupField by jpt 3 years, 3 months ago
- Another pygments for ReST by limodou 5 years, 2 months ago
Comments