Skip to content
Myr

Allow to pass a list to native_concat

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

authored by Martin Krizek · committed by Martin Krizek · parent fe3dada · Browse files · 2 files+11 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

2 files+11 added−1 removed

  • tests:+6 added−0 removed
  • other:+5 added−1 removed

2 files+11 added−1 removed

modified:jinja2/nativetypes.py+5 added-1 removed
1import sys2import types3from ast import literal_eval4from itertools import islice, chain5from jinja2 import nodes6from jinja2._compat import text_type
13 unmodified lines
2021 if not head:22 return None2324 if isinstance(nodes, types.GeneratorType):25 nodes = chain(head, nodes)2627 if len(head) == 1:28 out = head[0]29 else:26 out = u''.join([text_type(v) for v in chain(head, nodes)])30 out = u''.join([text_type(v) for v in nodes])3132 try:33 return literal_eval(out)34 except (ValueError, SyntaxError, MemoryError):
190 unmodified lines
modified:tests/test_nativetypes.py+6 added
106 unmodified lines
107 t = env.from_string("{{ true.__class__|string }}")108 result = t.render()109 assert not isinstance(result, type)110 assert result in ["<type 'bool'>", "<class 'bool'>"]111112 def test_string(self, env):113 t = env.from_string("[{{ 'all' }}]")114 result = t.render()115 assert isinstance(result, text_type)116 assert result == "[all]"