render_markup filter, specify the markup filter as a string

 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

  1. i18n base model for translatable content by foxbunny 3 years, 10 months ago
  2. Analogue template filter to removetags that also removes the content of the tag by piquadrat 1 year, 6 months ago
  3. Tags & filters for rendering search results by exogen 4 years, 2 months ago
  4. MarkupField by jpt 3 years, 3 months ago
  5. Another pygments for ReST by limodou 5 years, 2 months ago

Comments

(Forgotten your password?)