mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +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 import template
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@ -22,6 +23,8 @@ def textile(value):
|
|||||||
try:
|
try:
|
||||||
import textile
|
import textile
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
if settings.DEBUG:
|
||||||
|
raise template.TemplateSyntaxError, "Error in {% textile %} filter: The Python textile library isn't installed."
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
return textile.textile(value)
|
return textile.textile(value)
|
||||||
@ -30,6 +33,8 @@ def markdown(value):
|
|||||||
try:
|
try:
|
||||||
import markdown
|
import markdown
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
if settings.DEBUG:
|
||||||
|
raise template.TemplateSyntaxError, "Error in {% markdown %} filter: The Python markdown library isn't installed."
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
return markdown.markdown(value)
|
return markdown.markdown(value)
|
||||||
@ -38,6 +43,8 @@ def restructuredtext(value):
|
|||||||
try:
|
try:
|
||||||
from docutils.core import publish_parts
|
from docutils.core import publish_parts
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
if settings.DEBUG:
|
||||||
|
raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
parts = publish_parts(source=value, writer_name="html4css1")
|
parts = publish_parts(source=value, writer_name="html4css1")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user