From 8bcab55586a99461eb65f8f5b2204e74074ec1c2 Mon Sep 17 00:00:00 2001 From: Martin Asell Date: Sun, 13 Oct 2019 23:40:24 +0100 Subject: [PATCH] Fix indentation when iterating in scope --- chevron/renderer.py | 1 + test_spec.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/chevron/renderer.py b/chevron/renderer.py index 99415da..cf039e3 100644 --- a/chevron/renderer.py +++ b/chevron/renderer.py @@ -311,6 +311,7 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # Append it as the most recent scope and render new_scope = [thing] + scopes rend = render(template=tags, scopes=new_scope, + padding=padding, partials_path=partials_path, partials_ext=partials_ext, partials_dict=partials_dict, diff --git a/test_spec.py b/test_spec.py index 56bdea6..250d9b7 100755 --- a/test_spec.py +++ b/test_spec.py @@ -435,6 +435,23 @@ class ExpandedCoverage(unittest.TestCase): self.assertEqual(result, expected) + def test_iterator_scope_indentation(self): + args = { + 'data': { + 'thing': ['foo', 'bar', 'baz'], + }, + 'template': '{{> count }}', + 'partials_dict': { + 'count': ' {{> iter_scope }}', + 'iter_scope': 'foobar\n{{#thing}}\n {{.}}\n{{/thing}}' + } + } + + result = chevron.render(**args) + expected = ' foobar\n foo\n bar\n baz\n' + + self.assertEqual(result, expected) + # Run unit tests from command line if __name__ == "__main__": -- 2.47.3