Skip to content
Myr

Merge branch 'master' of github.com:mitsuhiko/jinja2

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

authored by Armin Ronacher · committed by Armin Ronacher · parents e7e14cf, b42f535 · Browse files · 24 files+177 added−134 removed
This commit

State

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

Diff stats

24 files+177 added−134 removed

  • tests:+53 added−15 removed
  • other:+124 added−119 removed

24 files+177 added−134 removed

added:.github/ISSUE_TEMPLATE.rst+2 added
1The issue tracker is a tool to address bugs.2Please use the #pocoo IRC channel on freenode or Stack Overflow for questions.
modified:docs/_templates/sidebarintro.html+1 added-1 removed
modified:docs/api.rst+2 added-2 removed
17 unmodified lines
18:class:`Template` class, an environment is created automatically for you,19albeit a shared one.2021Most applications will create one :class:`Environment` object on application22initialization and use that to load templates. In some cases it's however22initialization and use that to load templates. In some cases however, it's 23useful to have multiple environments side by side, if different configurations24are in use.2526The simplest way to configure Jinja2 to load templates for your application
553 unmodified lines
580Custom Filters581--------------582583Custom filters are just regular Python functions that take the left side of584the filter as first argument and the the arguments passed to the filter as584the filter as first argument and the arguments passed to the filter as585extra arguments or keyword arguments.586587For example in the filter ``{{ 42|myfilter(23) }}`` the function would be588called with ``myfilter(42, 23)``. Here for example a simple filter that can
220 unmodified lines
modified:docs/extensions.rst+1 added-1 removed
105 unmodified lines
106The usage of the `i18n` extension for template designers is covered as part107:ref:`of the template documentation <i18n-in-templates>`.108109.. _gettext: http://docs.python.org/dev/library/gettext110.. _Babel: http://babel.edgewall.org/110.. _Babel: http://babel.pocoo.org/111112.. _newstyle-gettext:113114Newstyle Gettext
232 unmodified lines
modified:docs/faq.rst+2 added-2 removed
139 unmodified lines
140work in production environments::141142 import os143 if os.environ.get('SERVER_SOFTWARE', '').startswith('Dev'):144 from google.appengine.tools.dev_appserver import HardenedModulesHook145 HardenedModulesHook._WHITE_LIST_C_MODULES += ['_ctypes', 'gestalt']144 from google.appengine.tools.devappserver2.python import sandbox145 sandbox._WHITE_LIST_C_MODULES += ['_ctypes', 'gestalt']146147Credit for this snippet goes to `Thomas Johansson148<http://stackoverflow.com/questions/3086091/debug-jinja2-in-google-app-engine/3694434#3694434>`_149
42 unmodified lines
modified:docs/integration.rst+6 added-5 removed
4 unmodified lines
5the `Babel`_ library or your favourite editor for fancy code highlighting.6This is a brief description of whats included.78Files to help integration are available9`here. <https://github.com/mitsuhiko/jinja2/tree/master/ext>`_9`here. <https://github.com/pallets/jinja/tree/master/ext>`_1011.. _babel-integration:1213Babel Integration
35 unmodified lines
49 testsuites will catch syntax errors in templates anyways. If you don't50 want that behavior you can add ``silent=false`` to the settings and51 exceptions are propagated.5253.. _mapping file: http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration53.. _mapping file: http://babel.pocoo.org/en/latest/messages.html#extraction-method-mapping-and-configuration5455Pylons56------57
22 unmodified lines
8081TextMate82--------8384Inside the `ext` folder at the root of the Jinja2 project there is a bundle for85TextMate that supports syntax highlighting for Jinja1 and Jinja2 for text based84There is a `bundle for TextMate`_ that supports syntax highlighting for Jinja1 and Jinja2 for text based85templates as well as HTML. It also contains a few often used snippets.8687.. _bundle for TextMate: https://github.com/mitsuhiko/jinja2-tmbundle8889Vim90---9192A syntax plugin for `Vim`_ exists in the Vim-scripts directory as well as the
3 unmodified lines
96The first one for text based templates, the latter for HTML templates.9798Copy the files into your `syntax` folder.9999.. _Babel: http://babel.edgewall.org/100.. _Babel: http://babel.pocoo.org/101.. _Vim: http://www.vim.org/
modified:docs/intro.rst+3 added-6 removed
34 unmodified lines
3536This will install a Jinja2 egg in your Python installation's site-packages37directory.3839(If you are installing from the Windows command line omit the `sudo` and make40sure to run the command as user with administrator rights)4139From the tarball release40~~~~~~~~~~~~~~~~~~~~~~~~~41421. Download the most recent tarball from the `download page`_432. Unpack the tarball473. ``sudo python setup.py install``443. ``python setup.py install``4546Note that you either have to have `setuptools` or `distribute` installed;47the latter is preferred.48
2 unmodified lines
51Installing the development version52~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~53541. Install `git`_582. ``git clone git://github.com/mitsuhiko/jinja2.git``552. ``git clone git://github.com/pallets/jinja.git``563. ``cd jinja2``574. ``ln -s jinja2 /usr/lib/python2.X/site-packages``5859As an alternative to steps 4 you can also do ``python setup.py develop``
56 unmodified lines
116in mind, so you will have to adapt the shown code examples to Python 3 syntax117for yourself.118119123.. _Jinja bug tracker: http://github.com/mitsuhiko/jinja2/issues120.. _Jinja bug tracker: http://github.com/pallets/jinja/issues
modified:docs/templates.rst+2 added-2 removed
604 unmodified lines
605+-----------------------+---------------------------------------------------+606| `loop.cycle` | A helper function to cycle between a list of |607| | sequences. See the explanation below. |608+-----------------------+---------------------------------------------------+609| `loop.depth` | Indicates how deep in deep in a recursive loop |609| `loop.depth` | Indicates how deep in a recursive loop |610| | the rendering currently is. Starts at level 1 |611+-----------------------+---------------------------------------------------+612| `loop.depth0` | Indicates how deep in deep in a recursive loop |612| `loop.depth0` | Indicates how deep in a recursive loop |613| | the rendering currently is. Starts at level 0 |614+-----------------------+---------------------------------------------------+615616Within a for-loop, it's possible to cycle among a list of strings/variables
893 unmodified lines
modified:jinja2/_compat.py-3 removed
43 unmodified lines
4445 implements_iterator = _identity46 implements_to_string = _identity47 encode_filename = _identity48 get_next = lambda x: x.__next__4849else:50 unichr = unichr51 text_type = unicode
23 unmodified lines
75 cls.__unicode__ = cls.__str__76 cls.__str__ = lambda x: x.__unicode__().encode('utf-8')77 return cls7880 get_next = lambda x: x.next8179 def encode_filename(filename):80 if isinstance(filename, unicode):81 return filename.encode('utf-8')82 return filename
17 unmodified lines
modified:jinja2/environment.py+30 added-37 removed
8 unmodified lines
9 :license: BSD, see LICENSE for more details.10"""11import os12import sys13import weakref14from functools import reduce, partial15from jinja2 import nodes16from jinja2.defaults import BLOCK_START_STRING, \17 BLOCK_END_STRING, VARIABLE_START_STRING, VARIABLE_END_STRING, \18 COMMENT_START_STRING, COMMENT_END_STRING, LINE_STATEMENT_PREFIX, \
11 unmodified lines
30from jinja2.utils import import_string, LRUCache, Markup, missing, \31 concat, consume, internalcode32from jinja2._compat import imap, ifilter, string_types, iteritems, \33 text_type, reraise, implements_iterator, implements_to_string, \32 get_next, encode_filename, PY2, PYPY33from functools import reduce34 encode_filename, PY2, PYPY353637# for direct template usage we have up to ten living environments38_spontaneous_environments = LRUCache(10)
128 unmodified lines
167 as strings or extension classes. For more information have a168 look at :ref:`the extensions documentation <jinja-extensions>`.169170 `optimized`170 should the optimizer be enabled? Default is `True`.171 should the optimizer be enabled? Default is ``True``.172173 `undefined`174 :class:`Undefined` or a subclass of it that is used to represent175 undefined values in the template.176177 `finalize`178 A callable that can be used to process the result of a variable179 expression before it is output. For example one can convert179 `None` implicitly into an empty string here.180 ``None`` implicitly into an empty string here.181182 `autoescape`182 If set to true the XML/HTML autoescaping feature is enabled by183 If set to ``True`` the XML/HTML autoescaping feature is enabled by184 default. For more details about autoescaping see185 :class:`~jinja2.utils.Markup`. As of Jinja 2.4 this can also186 be a callable that is passed the template name and has to186 return `True` or `False` depending on autoescape should be187 return ``True`` or ``False`` depending on autoescape should be188 enabled by default.189190 .. versionchanged:: 2.4191 `autoescape` can now be a function
13 unmodified lines
205206 `auto_reload`207 Some loaders load templates from locations where the template208 sources may change (ie: file system or database). If208 `auto_reload` is set to `True` (default) every time a template is209 ``auto_reload`` is set to ``True`` (default) every time a template is210 requested the loader checks if the source changed and if yes, it211 will reload the template. For higher performance it's possible to212 disable that.213
555 unmodified lines
769 @internalcode770 def _load_template(self, name, globals):771 if self.loader is None:772 raise TypeError('no loader for this environment specified')772 try:773 # use abs path for cache key774 cache_key = self.loader.get_source(self, name)[1]775 except RuntimeError:776 # if loader does not implement get_source()777 cache_key = None778 # if template is not file, use name for cache key779 if cache_key is None:780 cache_key = name773 cache_key = (weakref.ref(self.loader), name)774 if self.cache is not None:775 template = self.cache.get(cache_key)776 if template is not None and (not self.auto_reload or777 template.is_up_to_date):
385 unmodified lines
1163 fp.close()11641165 def disable_buffering(self):1166 """Disable the output buffering."""1174 self._next = get_next(self._gen)1167 self._next = partial(next, self._gen)1168 self.buffered = False11691170 def _buffered_generator(self, size):1171 buf = []1172 c_size = 01173 push = buf.append11741175 while 1:1176 try:1177 while c_size < size:1178 c = next(self._gen)1179 push(c)1180 if c:1181 c_size += 11182 except StopIteration:1183 if not c_size:1184 return1185 yield concat(buf)1186 del buf[:]1187 c_size = 011881189 def enable_buffering(self, size=5):1190 """Enable buffering. Buffer `size` items before yielding them."""1191 if size <= 1:1192 raise ValueError('buffer size too small')11931182 def generator(next):1183 buf = []1184 c_size = 01185 push = buf.append11861187 while 1:1188 try:1189 while c_size < size:1190 c = next()1191 push(c)1192 if c:1193 c_size += 11194 except StopIteration:1195 if not c_size:1196 return1197 yield concat(buf)1198 del buf[:]1199 c_size = 012001194 self.buffered = True1202 self._next = get_next(generator(get_next(self._gen)))1195 self._next = partial(next, self._buffered_generator(size))11961197 def __iter__(self):1198 return self1199
7 unmodified lines
modified:jinja2/filters.py+35 added-29 removed
10 unmodified lines
11import re12import math1314from random import choice15from operator import itemgetter15from itertools import groupby16from collections import namedtuple17from jinja2.utils import Markup, escape, pformat, urlize, soft_unicode, \18 unicode_urlencode19from jinja2.runtime import Undefined20from jinja2.exceptions import FilterArgumentError21from jinja2._compat import imap, string_types, text_type, iteritems222324_word_re = re.compile(r'\w+(?u)')24_word_re = re.compile(r'\w+', re.UNICODE)25_word_beginning_split_re = re.compile(r'([-\s\(\{\[\<]+)', re.UNICODE)262728def contextfilter(f):29 """Decorator for marking context dependent filters. The current
14 unmodified lines
44 return f454647def environmentfilter(f):47 """Decorator for marking evironment dependent filters. The current48 """Decorator for marking environment dependent filters. The current49 :class:`Environment` is passed to the filter as first argument.50 """51 f.environmentfilter = True52 return f
130 unmodified lines
183def do_title(s):184 """Return a titlecased version of the value. I.e. words will start with185 uppercase letters, all remaining characters are lowercase.186 """186 rv = []187 for item in re.compile(r'([-\s]+)(?u)').split(soft_unicode(s)):188 if not item:189 continue190 rv.append(item[0].upper() + item[1:].lower())191 return ''.join(rv)187 return ''.join(188 [item[0].upper() + item[1:].lower()189 for item in _word_beginning_split_re.split(soft_unicode(s))190 if item])191192193def do_dictsort(value, case_sensitive=False, by='key'):194 """Sort a dict and yield (key, value) pairs. Because python dicts are
321 unmodified lines
516 override this default using the first parameter. You517 can also override the default base (10) in the second518 parameter, which handles input with prefixes such as519 0b, 0o and 0x for bases 2, 8 and 16 respectively.520 The base is ignored for decimal numbers and non-string values.521 """522 try:523 if isinstance(value, string_types):523 return int(value, base)524 return int(value, base)525 return int(value)526 except (TypeError, ValueError):527 # this quirk is necessary so that "42.23"|int gives 42.528 try:529 return int(float(value))
140 unmodified lines
670 func = getattr(math, method)671 return func(value * (10 ** precision)) / (10 ** precision)672673674_GroupTuple = namedtuple('_GroupTuple', ['grouper', 'list'])675676@environmentfilter677def do_groupby(environment, value, attribute):678 """Group a sequence of objects by a common attribute.679
32 unmodified lines
712 It's now possible to use dotted notation to group by the child713 attribute of another attribute.714 """715 expr = make_attrgetter(environment, attribute)712 return sorted(map(_GroupTuple, groupby(sorted(value, key=expr), expr)))716 return [_GroupTuple(key, list(values)) for key, values in groupby(sorted(value, key=expr), expr)]717718715class _GroupTuple(tuple):716 __slots__ = ()717 grouper = property(itemgetter(0))718 list = property(itemgetter(1))719720 def __new__(cls, xxx_todo_changeme):721 (key, value) = xxx_todo_changeme722 return tuple.__new__(cls, (key, list(value)))723724719@environmentfilter720def do_sum(environment, iterable, attribute=None, start=0):721 """Returns the sum of a sequence of numbers plus the value of parameter722 'start' (which defaults to 0). When the sequence is empty it returns
122 unmodified lines
845846847@contextfilter848def do_select(*args, **kwargs):855 """Filters a sequence of objects by applying a test to the object and only856 selecting the ones with the test succeeding.849 """Filters a sequence of objects by applying a test to each object,850 and only selecting the objects with the test succeeding.851852 If no test is specified, each object will be evaluated as a boolean.853854 Example usage:855856 .. sourcecode:: jinja857
6 unmodified lines
864865866@contextfilter867def do_reject(*args, **kwargs):872 """Filters a sequence of objects by applying a test to the object and873 rejecting the ones with the test succeeding.868 """Filters a sequence of objects by applying a test to each object,869 and rejecting the objects with the test succeeding.870871 If no test is specified, each object will be evaluated as a boolean.872873 Example usage:874875 .. sourcecode:: jinja876
5 unmodified lines
882883884@contextfilter885def do_selectattr(*args, **kwargs):888 """Filters a sequence of objects by applying a test to an attribute of an889 object and only selecting the ones with the test succeeding.886 """Filters a sequence of objects by applying a test to the specified887 attribute of each object, and only selecting the objects with the888 test succeeding.889890 If no test is specified, the attribute's value will be evaluated as891 a boolean.892893 Example usage:894895 .. sourcecode:: jinja896
6 unmodified lines
903904905@contextfilter906def do_rejectattr(*args, **kwargs):905 """Filters a sequence of objects by applying a test to an attribute of an906 object or the attribute and rejecting the ones with the test succeeding.907 """Filters a sequence of objects by applying a test to the specified908 attribute of each object, and rejecting the objects with the test909 succeeding.910911 If no test is specified, the attribute's value will be evaluated as912 a boolean.913914 .. sourcecode:: jinja915916 {{ users|rejectattr("is_active") }}917 {{ users|rejectattr("email", "none") }}
85 unmodified lines
modified:jinja2/loaders.py+2 added-2 removed
349 unmodified lines
350 loader, name = self.get_loader(template)351 try:352 return loader.get_source(environment, name)353 except TemplateNotFound:354 # re-raise the exception with the correct fileame here.354 # re-raise the exception with the correct filename here.355 # (the one that includes the prefix)356 raise TemplateNotFound(template)357358 @internalcode
1 unmodified line
360 loader, local_name = self.get_loader(name)361 try:362 return loader.load(environment, local_name, globals)363 except TemplateNotFound:364 # re-raise the exception with the correct fileame here.364 # re-raise the exception with the correct filename here.365 # (the one that includes the prefix)366 raise TemplateNotFound(name)367368 def list_templates(self):
113 unmodified lines
modified:jinja2/utils.py+2 added-2 removed
107 unmodified lines
108def clear_caches():109 """Jinja2 keeps internal caches for environments and lexers. These are110 used so that Jinja2 doesn't have to recreate environments and lexers all111 the time. Normally you don't have to care about that but if you are112 messuring memory consumption you may want to clean the caches.112 measuring memory consumption you may want to clean the caches.113 """114 from jinja2.environment import _spontaneous_environments115 from jinja2.lexer import _lexer_cache116 _spontaneous_environments.clear()
85 unmodified lines
202 or '')) or x203 words = _word_split_re.split(text_type(escape(text)))204 nofollow_attr = nofollow and ' rel="nofollow"' or ''205 if target is not None and isinstance(target, string_types):206 target_attr = ' target="%s"' % target206 target_attr = ' target="%s"' % escape(target)207 else:208 target_attr = ''209 for i, word in enumerate(words):210 match = _punctuation_re.match(word)
321 unmodified lines
modified:tests/test_ext.py+4 added-4 removed
97 unmodified lines
98)99newstyle_i18n_env.install_gettext_callables(gettext, ngettext, newstyle=True)100101102class TestExtension(Extension):102class ExampleExtension(Extension):103 tags = set(['test'])104 ext_attr = 42105106 def parse(self, parser):
99 unmodified lines
206 assert [x.strip() for x in tmpl.render(a=1, b=2).splitlines()] \207 == ['42 = 23', '1 = 2']208209 def test_extension_nodes(self):210 env = Environment(extensions=[TestExtension])210 env = Environment(extensions=[ExampleExtension])211 tmpl = env.from_string('{% test %}')212 assert tmpl.render() == 'False|42|23|{}'213214 def test_identifier(self):215 assert TestExtension.identifier == __name__ + '.TestExtension'215 assert ExampleExtension.identifier == __name__ + '.ExampleExtension'216217 def test_rebinding(self):218 original = Environment(extensions=[TestExtension])218 original = Environment(extensions=[ExampleExtension])219 overlay = original.overlay()220 for env in original, overlay:221 for ext in itervalues(env.extensions):222 assert ext.environment is env
245 unmodified lines
modified:tests/test_filters.py+16 added-3 removed
131 unmodified lines
132 assert out == ('foo bar foo bar\n foo bar foo bar| '133 'foo bar foo bar\n foo bar foo bar')134135 def test_int(self, env):136 class IntIsh(object):137 def __int__(self):138 return 42139140 tmpl = env.from_string('{{ "42"|int }}|{{ "ajsghasjgd"|int }}|'141 '{{ "32.32"|int }}|{{ "0x4d32"|int(0, 16) }}|'138 '{{ "011"|int(0, 8)}}|{{ "0x33FU"|int(0, 16) }}')139 out = tmpl.render()140 assert out == '42|0|32|19762|9|0'142 '{{ "011"|int(0, 8)}}|{{ "0x33FU"|int(0, 16) }}|'143 '{{ obj|int }}')144 out = tmpl.render(obj=IntIsh())145 assert out == '42|0|32|19762|9|0|42'146147 def test_join(self, env):148 tmpl = env.from_string('{{ [1, 2, 3]|join("|") }}')149 out = tmpl.render()
62 unmodified lines
212 tmpl = env.from_string('''{{ "foo\tbar"|title }}''')213 assert tmpl.render() == "Foo\tBar"214 tmpl = env.from_string('''{{ "FOO\tBAR"|title }}''')215 assert tmpl.render() == "Foo\tBar"216 tmpl = env.from_string('''{{ "foo (bar)"|title }}''')217 assert tmpl.render() == "Foo (Bar)"218 tmpl = env.from_string('''{{ "foo {bar}"|title }}''')219 assert tmpl.render() == "Foo {Bar}"220 tmpl = env.from_string('''{{ "foo [bar]"|title }}''')221 assert tmpl.render() == "Foo [Bar]"222 tmpl = env.from_string('''{{ "foo <bar>"|title }}''')223 assert tmpl.render() == "Foo <Bar>"224225 class Foo:226 def __str__(self):227 return 'foo-bar'
344 unmodified lines
modified:tests/test_loader.py+21 added-7 removed
11 unmodified lines
12import sys13import tempfile14import shutil15import pytest16import weakref1718from jinja2 import Environment, loaders19from jinja2._compat import PYPY, PY220from jinja2.loaders import split_template_path
57 unmodified lines
78 changed = True79 assert tmpl is not env.get_template('template')80 changed = False8181 env = Environment(loader=TestLoader(), cache_size=0)82 assert env.get_template('template') \83 is not env.get_template('template')82 def test_no_cache(self):83 mapping = {'foo': 'one'}84 env = Environment(loader=loaders.DictLoader(mapping), cache_size=0)85 assert env.get_template('foo') is not env.get_template('foo')8687 def test_limited_size_cache(self):88 mapping = {'one': 'foo', 'two': 'bar', 'three': 'baz'}89 loader = loaders.DictLoader(mapping)85 env = Environment(loader=TestLoader(), cache_size=2)90 env = Environment(loader=loader, cache_size=2)91 t1 = env.get_template('one')92 t2 = env.get_template('two')93 assert t2 is env.get_template('two')94 assert t1 is env.get_template('one')95 t3 = env.get_template('three')91 assert 'one' in env.cache92 assert 'two' not in env.cache93 assert 'three' in env.cache96 loader_ref = weakref.ref(loader)97 assert (loader_ref, 'one') in env.cache98 assert (loader_ref, 'two') not in env.cache99 assert (loader_ref, 'three') in env.cache100101 def test_cache_loader_change(self):102 loader1 = loaders.DictLoader({'foo': 'one'})103 loader2 = loaders.DictLoader({'foo': 'two'})104 env = Environment(loader=loader1, cache_size=2)105 assert env.get_template('foo').render() == 'one'106 env.loader = loader2107 assert env.get_template('foo').render() == 'two'108109 def test_dict_loader_cache_invalidates(self):110 mapping = {'foo': "one"}111 env = Environment(loader=loaders.DictLoader(mapping))112 assert env.get_template('foo').render() == "one"
122 unmodified lines
modified:tests/test_utils.py+12 added-1 removed
12 unmodified lines
13import pytest1415import pickle1617from jinja2.utils import LRUCache, escape, object_type_repr17from jinja2.utils import LRUCache, escape, object_type_repr, urlize181920@pytest.mark.utils21@pytest.mark.lrucache
51 unmodified lines
73 escape(u"foo")74 escape(u"<foo>")75 counts.add(len(gc.get_objects()))76 assert len(counts) == 1, 'ouch, c extension seems to leak objects'777879@pytest.mark.utils80@pytest.mark.escapeUrlizeTarget81class TestEscapeUrlizeTarget():82 def test_escape_urlize_target(self):83 url = "http://example.org"84 target = "<script>"85 assert urlize(url, target=target) == ('<a href="http://example.org"'86 ' target="&lt;script&gt;">'87 'http://example.org</a>')
modified:.gitignore+7 added-5 removed
1*.so2docs/_build2docs/_build/3*.pyc4*.pyo5*.egg-info5*.egg-info/6*.egg7build8dist7build/8dist/9.DS_Store10.tox10.tox/11.cache/12.idea/
modified:.travis.yml+5 added-7 removed
1sudo: false2language: python3python:4 - "2.6"5 - "2.7"6 - pypy7 - "3.3"8 - "3.4"9 - "3.5"8 - "pypy"910install:11 - pip install tox11 - pip install tox12script:13 - tox -e \14 $(echo $TRAVIS_PYTHON_VERSION | sed 's/^\([0-9]\)\.\([0-9]\).*/py\1\2/')1513 - tox -e py14notifications:15 email: false16 irc:17 channels:20 - "chat.freenode.net#pocoo"18 - chat.freenode.net#pocoo19 on_success: change20 on_failure: always21 use_notice: true22 skip_join: true
modified:CHANGES+7 added-4 removed
2 unmodified lines
34Version 2.95-----------67- Change cache key definition in environment. This fixes a performance8 regression introduced in 2.8.9- Added support for `generator_stop` on supported Python versions10 (Python 3.5 and later)1112Version 2.8.1
1 unmodified line
1415(unreleased bugfix release)1617- Fixed the `for_qs` flag for `urlencode`.18- Fixed regression when applying `int` to non-string values.1920Version 2.821-----------22(codename Replacement, released on July 26th 2015)
11 unmodified lines
34 object that logs failures into a logger.35- If unmarshalling of cached data fails the template will be36 reloaded now.37- Implemented a block ``set`` tag.35- Default cache size was incrased to 400 from a low 50.38- Default cache size was increased to 400 from a low 50.39- Fixed ``is number`` test to accept long integers in all Python versions.40- Changed ``is number`` to accept Decimal as a number.41- Added a check for default arguments followed by non-default arguments. This42 change makes ``{% macro m(x, y=1, z) %}...{% endmacro %}`` a syntax error. The
97 unmodified lines
140 to upgrade, it's enough to flush the bytecode cache. This just no longer141 makes this necessary, Jinja2 will automatically detect these cases now.142- the sum filter can now sum up values by attribute. This is a backwards143 incompatible change. The argument to the filter previously was the141 optional starting index which defaultes to zero. This now became the144 optional starting index which defaults to zero. This now became the145 second argument to the function because it's rarely used.146- like sum, sort now also makes it possible to order items by attribute.147- like sum and sort, join now also is able to join attributes of objects148 as string.
49 unmodified lines
198 compatibility the pure Python implementation still exists but is199 pulled from markupsafe by the Jinja2 developers. The debug support200 went into a separate feature called "debugsupport" and is disabled201 by default because it is only relevant for Python 2.4199- fixed an issue with unary operators having the wrong precendence.202- fixed an issue with unary operators having the wrong precedence.203204Version 2.5205-----------203(codename Incoherence, relased on May 29th 2010)206(codename Incoherence, released on May 29th 2010)207208- improved the sort filter (should have worked like this for a209 long time) by adding support for case insensitive searches.210- fixed a bug for getattribute constant folding.
174 unmodified lines
modified:README.rst+9 added-7 removed
6 unmodified lines
78Nutshell9--------1011Here a small example of a Jinja template::11Here a small example of a Jinja template:1213.. code-block:: jinja1415 {% extends 'base.html' %}16 {% block title %}Memberlist{% endblock %}17 {% block content %}18 <ul>
10 unmodified lines
29life difficult by restricting functionality too much.3031For more information visit the new `Jinja2 webpage`_ and `documentation`_.3231The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install32Jinja2==dev``.33The `Jinja2 tip`_ is installable via ``pip`` with ``pip install34https://github.com/pallets/jinja/zipball/master``.3536.. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)37.. _Django: http://www.djangoproject.com/38.. _Jinja2 webpage: http://jinja.pocoo.org/
3 unmodified lines
42Builds43------4445+---------------------+------------------------------------------------------------------------------+44| ``master`` | .. image:: https://travis-ci.org/mitsuhiko/jinja2.svg?branch=master |45| | :target: https://travis-ci.org/mitsuhiko/jinja2 |46| ``master`` | .. image:: https://travis-ci.org/pallets/jinja.svg?branch=master |47| | :target: https://travis-ci.org/pallets/jinja |48+---------------------+------------------------------------------------------------------------------+47| ``2.7-maintenance`` | .. image:: https://travis-ci.org/mitsuhiko/jinja2.svg?branch=2.7-maintenance |48| | :target: https://travis-ci.org/mitsuhiko/jinja2 |49| ``2.7-maintenance`` | .. image:: https://travis-ci.org/pallets/jinja.svg?branch=2.7-maintenance |50| | :target: https://travis-ci.org/pallets/jinja |51+---------------------+------------------------------------------------------------------------------+
modified:setup.cfg+3 added
1[wheel]2universal = 134[metadata]5license_file = LICENSE67[aliases]8release = egg_info -RDb ''910[pytest]
1 unmodified line
modified:setup.py+2 added
60 unmodified lines
61 'Programming Language :: Python :: 2.6',62 'Programming Language :: Python :: 2.7',63 'Programming Language :: Python :: 3',64 'Programming Language :: Python :: 3.3',65 'Programming Language :: Python :: 3.4',66 'Programming Language :: Python :: 3.5',67 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',68 'Topic :: Software Development :: Libraries :: Python Modules',69 'Topic :: Text Processing :: Markup :: HTML'70 ],
9 unmodified lines
modified:tox.ini+3 added-4 removed
1[tox]2envlist = py26, py27, pypy, py33, py34, py352envlist = py26,py27,pypy,py33,py34,py3534[testenv]5commands =6 py.test []5commands = py.test {posargs}67deps =9 pytest8 pytest