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 4 years, 10 months ago
  2. Function/Stored Procedure Manager by axiak 5 years, 11 months ago
  3. MarkupField by jpt 4 years, 2 months ago
  4. integrated jinja2 which could use generic view ,my djangojinja2.py by jasongreen 3 years, 4 months ago
  5. MarkupTextField by myles 4 years, 6 months ago

Comments

(Forgotten your password?)