from .main import main, cli_main
from .renderer import render
-from .tokenizer import UnclosedSection
-__all__ = ['main', 'render', 'UnclosedSection', 'cli_main']
+__all__ = ['main', 'render', 'cli_main']
#!/usr/bin/python
-class UnclosedSection(Exception):
- """Raised when you have unbalanced section tags"""
- pass
-
-
def tokenize(template, def_ldel='{{', def_rdel='}}'):
"""Tokenize a mustache template
last_section = open_sections.pop()
if tag_key != last_section:
# Otherwise we need to complain
- raise UnclosedSection()
+ raise SyntaxError("End tag does not match ."
+ "the currently opened section")
# Check right side if we might be a standalone
if is_standalone and tag_type not in ['variable', 'no escape']:
# If there are any open sections when we're done
if open_sections:
# Then we need to complain
- raise UnclosedSection()
+ raise SyntaxError("End of file while a section was open")
'template': '{{# section }} end of file'
}
- self.assertRaises(chevron.tokenizer.UnclosedSection,
- chevron.render, **test1)
- self.assertRaises(chevron.tokenizer.UnclosedSection,
- chevron.render, **test2)
+ self.assertRaises(SyntaxError, chevron.render, **test1)
+ self.assertRaises(SyntaxError, chevron.render, **test2)
def test_unicode_basic(self):
args = {