wordwrap filter should use the newline_sequence defined in current Environment object
authorsevas <f.degroef@gmail.com>
Sun, 1 May 2011 21:28:25 +0000 (23:28 +0200)
committersevas <f.degroef@gmail.com>
Sun, 1 May 2011 21:28:25 +0000 (23:28 +0200)
jinja2/filters.py

index c5782e2da02fd4523fc8bc1719f3d8e26dc949d7..5b394ded66ae25926f159e21b89f0708533bb689 100644 (file)
@@ -443,8 +443,8 @@ def do_truncate(s, length=255, killwords=False, end='...'):
     result.append(end)
     return u' '.join(result)
 
-
-def do_wordwrap(s, width=79, break_long_words=True):
+@environmentfilter
+def do_wordwrap(environment, s, width=79, break_long_words=True):
     """
     Return a copy of the string passed to the filter wrapped after
     ``79`` characters.  You can override this default using the first
@@ -452,7 +452,7 @@ def do_wordwrap(s, width=79, break_long_words=True):
     split words apart if they are longer than `width`.
     """
     import textwrap
-    return u'\n'.join(textwrap.wrap(s, width=width, expand_tabs=False,
+    return environment.newline_sequence.join(textwrap.wrap(s, width=width, expand_tabs=False,
                                    replace_whitespace=False,
                                    break_long_words=break_long_words))