pystache.parser module

Exposes a parse() function to parse template strings.

exception pystache.parser.ParsingError[source]

Bases: Exception

pystache.parser.parse(template, delimiters=None)[source]

Parse a unicode template string and return a ParsedTemplate instance.

Arguments:

template: a unicode template string.

delimiters: a 2-tuple of delimiters. Defaults to the package default.

Examples:

>>> parsed = parse("Hey {{#who}}{{name}}!{{/who}}")
>>> print(str(parsed).replace('u', ''))  # This is an old hack.
['Hey ', _SectionNode(key='who', index_begin=12, index_end=21, parsed=[_EscapeNode(key='name'), '!'])]