]> Devi Nivas Git - chevron.git/commitdiff
correct error for badly closed tag
authorSamuel Colvin <s@muelcolvin.com>
Sun, 2 Jul 2017 10:26:29 +0000 (11:26 +0100)
committerSamuel Colvin <s@muelcolvin.com>
Sun, 2 Jul 2017 10:50:49 +0000 (11:50 +0100)
chevron/tokenizer.py
test_spec.py

index ea3f6b2b0df15bfd4a40ad66a982ea170b3e9ca9..ed5799ef0ce606976b22670294ef73bc49c2e2e8 100644 (file)
@@ -79,7 +79,11 @@ def parse_tag(template, l_del, r_del):
     }
 
     # Get the tag
-    tag, template = template.split(r_del, 1)
+    try:
+        tag, template = template.split(r_del, 1)
+    except ValueError:
+        raise ChevronError('unclosed tag '
+                           'at line {0}'.format(_CURRENT_LINE))
 
     # Find the type meaning of the first character
     tag_type = tag_types.get(tag[0], 'variable')
index 4fb5d146f615e37bb18bbda37a4336fef0488c88..5b3481152700af9a6ff2dc1f5296db7a1d957be4 100755 (executable)
@@ -194,6 +194,14 @@ class ExpandedCoverage(unittest.TestCase):
 
         self.assertEqual(result, expected)
 
+    def test_closing_tag_only(self):
+        args = {
+            'template': '{{ foo } bar',
+            'data': {'foo': 'xx'}
+        }
+
+        self.assertRaises(chevron.ChevronError, chevron.render, **args)
+
 
 # Run unit tests from command line
 if __name__ == "__main__":