- Fix a bug that caused callable objects with ``__getattr__``, like
:class:`~unittest.mock.Mock` to be treated as a
:func:`contextfunction`. :issue:`1145`
-
+ - Update ``wordcount`` filter to trigger :class:`Undefined` methods
- by wrapping the input in :func:`soft_unicode`. :pr:`1160`
-
++ by wrapping the input in :func:`soft_str`. :pr:`1160`
Version 2.11.1
--------------
def do_wordcount(s):
"""Count the words in that string."""
- return len(_word_re.findall(s))
- return len(_word_re.findall(soft_unicode(s)))
++ return len(_word_re.findall(soft_str(s)))
def do_int(value, default=0, base=10):
from jinja2 import Environment
from jinja2 import Markup
-from jinja2._compat import implements_to_string
-from jinja2._compat import text_type
+ from jinja2 import StrictUndefined
+ from jinja2 import UndefinedError
-@implements_to_string
-class Magic(object):
+class Magic:
def __init__(self, value):
self.value = value