projects
/
jinja2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
cda43df
)
changed wordcount filter once more
author
Armin Ronacher
<armin.ronacher@active-4.com>
Sat, 3 May 2008 17:04:02 +0000
(19:04 +0200)
committer
Armin Ronacher
<armin.ronacher@active-4.com>
Sat, 3 May 2008 17:04:02 +0000
(19:04 +0200)
--HG--
branch : trunk
jinja2/filters.py
patch
|
blob
|
history
diff --git
a/jinja2/filters.py
b/jinja2/filters.py
index 50171563ef9c4e59229ad8847c5ec7ef24cd7ea6..ec0186c147648d4493dfd23f52fcdf5a1ea0780d 100644
(file)
--- a/
jinja2/filters.py
+++ b/
jinja2/filters.py
@@
-20,6
+20,7
@@
from jinja2.exceptions import FilterArgumentError
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
+_word_re = re.compile(r'\w+')
def contextfilter(f):
@@
-373,7
+374,7
@@
def do_wordwrap(s, width=79, break_long_words=True):
def do_wordcount(s):
"""Count the words in that string."""
- return len(
s.split(
))
+ return len(
_word_re.findall(s
))
def do_int(value, default=0):