]> Devi Nivas Git - chevron.git/commitdiff
Fix indentation when iterating in scope
authorMartin Asell <martin.asell@localhost>
Sun, 13 Oct 2019 22:40:24 +0000 (23:40 +0100)
committerMartin Asell <martin.asell@localhost>
Sun, 13 Oct 2019 22:40:24 +0000 (23:40 +0100)
chevron/renderer.py
test_spec.py

index 99415da97fbea56901e1fc7900d16b77c2e24680..cf039e35172bf712256b73c91541fe567b632f0e 100644 (file)
@@ -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,
index 56bdea6bc4b8a5abb6b38cd41098cf2ef54c5576..250d9b7db53422e30122f5c431e7ac654ea078ad 100755 (executable)
@@ -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__":