Skip to content
Myr

changed wordcount filter once more

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent cda43df · Browse files · 1 file+2 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−1 removed

  • other:+2 added−1 removed

1 file+2 added−1 removed

modified:jinja2/filters.py+2 added-1 removed
18 unmodified lines
19from jinja2.exceptions import FilterArgumentError202122_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')23_word_re = re.compile(r'\w+')242526def contextfilter(f):27 """Decorator for marking context dependent filters. The current context
345 unmodified lines
373374375def do_wordcount(s):376 """Count the words in that string."""376 return len(s.split())377 return len(_word_re.findall(s))378379380def do_int(value, default=0):381 """Convert the value into an integer. If the
284 unmodified lines