mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
magic-removal: Fixed #1204 -- Markup filters now raise a TemplateSyntaxError if the Python libraries aren't installed and DEBUG=True
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2730 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1e72a7f672
commit
45be99d486
@ -15,6 +15,7 @@ silently fail and return the un-marked-up text.
|
||||
"""
|
||||
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@ -22,6 +23,8 @@ def textile(value):
|
||||
try:
|
||||
import textile
|
||||
except ImportError:
|
||||
if settings.DEBUG:
|
||||
raise template.TemplateSyntaxError, "Error in {% textile %} filter: The Python textile library isn't installed."
|
||||
return value
|
||||
else:
|
||||
return textile.textile(value)
|
||||
@ -30,6 +33,8 @@ def markdown(value):
|
||||
try:
|
||||
import markdown
|
||||
except ImportError:
|
||||
if settings.DEBUG:
|
||||
raise template.TemplateSyntaxError, "Error in {% markdown %} filter: The Python markdown library isn't installed."
|
||||
return value
|
||||
else:
|
||||
return markdown.markdown(value)
|
||||
@ -38,6 +43,8 @@ def restructuredtext(value):
|
||||
try:
|
||||
from docutils.core import publish_parts
|
||||
except ImportError:
|
||||
if settings.DEBUG:
|
||||
raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
|
||||
return value
|
||||
else:
|
||||
parts = publish_parts(source=value, writer_name="html4css1")
|
||||
|
Loading…
x
Reference in New Issue
Block a user