Skip to content

Commit

Permalink
Merge pull request pallets#30 from sevas/wordwrap-newline
Browse files Browse the repository at this point in the history
wordwrap filter should use the newline_sequence defined in current Environment
  • Loading branch information
mitsuhiko committed May 7, 2011
2 parents fbfc9d2 + 218cb64 commit 7c97352
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jinja2/filters.py
Expand Up @@ -443,16 +443,16 @@ 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
parameter. If you set the second parameter to `false` Jinja will not
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))

Expand Down

0 comments on commit 7c97352

Please sign in to comment.