summaryrefslogtreecommitdiff
path: root/jinja2/runtime.py
Commit message (Collapse)AuthorAgeFilesLines
* don't prefetch next item in loop contextDavid Lord2019-11-071-94/+157
|
* fixing LoopContext, loops indexing and iterator length propertyaayushuppal2019-10-141-12/+11
|
* Don't make cond_expr_undefined configurableAdrian Moennich2019-10-131-1/+1
|
* Fix bug with when using Markup on ChainableUndefinedLaurence de Bruxelles2019-10-041-4/+7
| | | | | | | | | Wrapping a ChainableUndefined object with Markup causes an UndefinedError because Markup thinks that ChainableUndefined has an attribute called __html__ and tries to call it. This commit fixes this by defining a method __html__ that calls ChainableUndefined.__str__. We also add a regression test.
* Fix simple typo: problemtic -> problematic (#1059)Tim Gates2019-09-041-3/+2
| | | Plus rephrase the comment for greater clarity.
* Fix typoMin ho Kim2019-07-251-1/+1
|
* Apply suggestionsMin ho Kim2019-07-071-1/+1
|
* Fix typoMin ho Kim2019-07-071-1/+1
|
* Fix typo "the the"Jon Dufresne2019-06-211-1/+1
|
* Add ChainableUndefined allowing getattr & getitem (#997)Étienne Pelletier2019-05-081-3/+30
| | | | | | | | | | | | | | * Add ChainableUndefined allowing getattr & getitem Allows using default values with chains of items or attributes that may contain undefined values without raising a jinja2.exceptions.UndefinedError. >>> import jinja2 >>> env = jinja2.Environment(undefined=jinja2.ChainableUndefined) >>> env.from_string("{{ foo.bar['baz'] | default('val') }}").render() 'val' * Remove class decorator from ChainableUndefined
* Import abstract base classes from collections.abcFlorian Bruhin2018-08-071-7/+2
| | | | | | | | | | | | | | | | In Python 3.7, importing ABCs directly from the `collections` module shows a warning (and in Python 3.8 it will stop working) - see https://github.com/python/cpython/commit/c66f9f8d3909f588c251957d499599a1680e2320 This fixes various DeprecationWarnings such as those: ``` .../jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import MutableMapping .../jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Mapping ```
* Merge pull request #502 from berrange/callableDavid Lord2017-07-071-7/+8
|\ | | | | runtime: avoid assumption that all objects provide __call__
| * runtime: avoid assumption that all objects provide __call__Daniel P. Berrange2015-10-131-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Objects which are backed by native extensions do not provide a __call__ attribute, but are none the less callable if the native extension provides a 'tp_call' implementation. The jinja2.runtime.Context.call method unconditionally access the '__call__' attribute causing an exception to be raised if the object was a native extension method. A demo of the problem can be seen using PyGObject: $ cat demo.py #!/usr/bin/python from gi.repository import Gio from jinja2 import Environment f = Gio.File.new_for_path("/some/file.txt") print f.get_uri() t = Environment().from_string("""{{f.get_uri()}}""") print t.render(f=f) Which when run results in $ ./demo.py file:///some/file.txt Traceback (most recent call last): File "./demo.py", line 10, in <module> print t.render(f=f) File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "<template>", line 1, in top-level template code AttributeError: 'gi.FunctionInfo' object has no attribute '__call__' After this patch it produces $ ./demo.py file:///some/file.txt file:///some/file.txt Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* | Add support for namespace attribute assignmentAdrian Moennich2017-06-241-2/+2
| |
* | Add changed() to loop contextAdrian Moennich2017-06-241-0/+8
| |
* | Add previtem/nextitem to loop contextAdrian Moennich2017-06-241-5/+22
| | | | | | | | related: #641
* | Fix custom contexts in fast resolve modeAdrian Moennich2017-03-151-1/+3
| | | | | | | | closes #675
* | Fixed async macro autoescape. Fixes #671Armin Ronacher2017-01-281-0/+4
| |
* | Add support back for custom resolves on old resolve methodArmin Ronacher2017-01-121-10/+58
| |
* | Fixed some string literal warnings. Fixes #646Armin Ronacher2017-01-081-1/+1
| |
* | Support new scoping rules in scoped blocksArmin Ronacher2017-01-081-3/+5
| |
* | Add support for explicit callersArmin Ronacher2017-01-081-1/+15
| | | | | | | | | | | | | | | | | | This adds support for a never intended Jinja2 feature which however worked in limited support before due to a bug with the identifier scoping. A quick github code search indicates that developers commonly did this to set the default caller to none. This fixes #642
* | Bump up the copyright to 2017Armin Ronacher2017-01-071-1/+1
| |
* | Generalize scoping. This fixes #603Armin Ronacher2017-01-071-2/+7
| |
* | Fixed self references in macrosArmin Ronacher2017-01-061-1/+3
| |
* | Set macro autoescape behavior at call instead of compile time. Fixes #565Armin Ronacher2017-01-061-3/+35
| |
* | Do not emit make_logging_undefined to runtimeArmin Ronacher2017-01-051-1/+1
| |
* | Changed behavior of macro defaults to be frame boundArmin Ronacher2017-01-031-7/+2
| |
* | First pass on integrating id trackingArmin Ronacher2017-01-031-6/+13
| |
* | Changelog and __rsub__ handlingArmin Ronacher2017-01-031-1/+1
| |
* | Merge pull request #530 from nick-garcia/masterArmin Ronacher2017-01-031-1/+1
|\ \ | | | | | | Subtraction from Undefined does not raise UndefinedError
| * | Setting __sub__ equal to _fail_with_undefined_error so subtractions withNick Garcia2016-01-071-1/+1
| |/ | | | | | | undefined variables will fail properly like other arithemtic operations.
* | Support the same set of loop functions for async modeArmin Ronacher2016-12-281-24/+24
| |
* | Added support for async loop contextArmin Ronacher2016-12-281-12/+21
|/
* Let the Environment override the ContextThiefMaster2015-04-061-1/+2
| | | | closes #404
* Fix doctestsMarkus Unterwaditzer2015-03-221-7/+7
| | | | Fix #427
* Fixed a Python 3 regression.Armin Ronacher2014-06-061-10/+16
|
* Added tests for logging undefined and added it to the docs.Armin Ronacher2014-06-061-18/+61
|
* Added support for logging of undefined objects.Armin Ronacher2014-06-061-6/+41
| | | | | | fixup! fixup!
* Fix loop context length calculation for iterators. Fixes #244Christoph Reiter2014-03-301-2/+3
| | | | | This resulted in wrong values for revindex and revindex0 while looping over an iterator.
* Merge branch '2.7-maintenance'Armin Ronacher2013-08-071-1/+11
|\
| * Fixed warnings if Python is run with -3.Armin Ronacher2013-08-071-1/+11
| | | | | | | | | | | | | | This also adds proper hashing and comparision support to undefined objects. This fixes #224
* | Since we no longer support 2.5 we can use the builtin next() functionArmin Ronacher2013-05-201-1/+1
|/
* Documented loop.depth and added loop.depth0.Armin Ronacher2013-05-201-2/+4
|
* feature to version check for context dict methodsArmin Ronacher2013-05-201-2/+2
|
* Removed an unnecessary checkArmin Ronacher2013-05-201-8/+7
|
* Make the runtime leak less of the version hacksArmin Ronacher2013-05-201-13/+13
|
* Added unicode mixin for unified string logicArmin Ronacher2013-05-191-17/+3
|
* PY3 -> PY2 macroArmin Ronacher2013-05-191-7/+7
|
* Moved all six usages (ignoring testsuite) into jinja2._compatArmin Ronacher2013-05-191-19/+24
|