silence warning about allow_lazy
@@ -3,7 +3,16 @@ import re
from django import template
from django.utils.encoding import force_text
+try:
+ from django.utils.functional import keep_lazy
+except ImportError:
+ # django < 1.10
from django.utils.functional import allow_lazy
+ # bare version for remove_spaces
+ def keep_lazy(*args):
+ def decorator(func):
+ return allow_lazy(func, *args)
+ return decorator
from crispy_forms.compatibility import text_type
@@ -11,14 +20,12 @@ from crispy_forms.compatibility import text_type
register = template.Library()
+@keep_lazy(text_type)
def remove_spaces(value):
html = re.sub(r'>\s{3,}<', '> <', force_text(value))
return re.sub(r'/><', r'/> <', force_text(html))
-remove_spaces = allow_lazy(remove_spaces, text_type)
-
-
class SpecialSpacelessNode(template.Node):
def __init__(self, nodelist):
self.nodelist = nodelist
