def __init__(self, text, *contexts):
self.text = text<EOL>self.context = {}<EOL>for context in contexts:<EOL><INDENT>self.context.update(context)<EOL><DEDENT>code = CodeBuilder()<EOL>code.add_line("<STR_LIT>")<EOL>code.indent()<EOL>vars_code = code.add_section()<EOL>self.all_vars = set()<EOL>self.loop_vars = set()<EOL>code.add_line("<STR_LIT>")<EOL>code.add_line("<STR_LIT>")<EOL>code.add_line("<STR_LIT>")<EOL>code.add_line("<STR_LIT>")<EOL>buffered = []<EOL>def flush_output():<EOL><INDENT>"""<STR_LIT>"""<EOL>if len(buffered) == <NUM_LIT:1>:<EOL><INDENT>code.add_line("<STR_LIT>" % buffered[<NUM_LIT:0>])<EOL><DEDENT>elif len(buffered) > <NUM_LIT:1>:<EOL><INDENT>code.add_line("<STR_LIT>" % "<STR_LIT:U+002C>".join(buffered))<EOL><DEDENT>del buffered[:]<EOL><DEDENT>toks = re.split(r"<STR_LIT>", text)<EOL>ops_stack = []<EOL>for tok in toks:<EOL><INDENT>if tok.startswith('<STR_LIT>'):<EOL><INDENT>buffered.append("<STR_LIT>" % self.expr_code(tok[<NUM_LIT:2>:-<NUM_LIT:2>].strip()))<EOL><DEDENT>elif tok.startswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>elif tok.startswith('<STR_LIT>'):<EOL><INDENT>flush_output()<EOL>words = tok[<NUM_LIT:2>:-<NUM_LIT:2>].strip().split()<EOL>if words[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>assert len(words) == <NUM_LIT:2><EOL>ops_stack.append('<STR_LIT>')<EOL>code.add_line("<STR_LIT>" % self.expr_code(words[<NUM_LIT:1>]))<EOL>code.indent()<EOL><DEDENT>elif words[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>assert len(words) == <NUM_LIT:4> and words[<NUM_LIT:2>] == '<STR_LIT>'<EOL>ops_stack.append('<STR_LIT>')<EOL>self.loop_vars.add(words[<NUM_LIT:1>])<EOL>code.add_line(<EOL>"<STR_LIT>" % (<EOL>words[<NUM_LIT:1>],<EOL>self.expr_code(words[<NUM_LIT:3>])<EOL>)<EOL>)<EOL>code.indent()<EOL><DEDENT>elif words[<NUM_LIT:0>].startswith('<STR_LIT:end>'):<EOL><INDENT>end_what = words[<NUM_LIT:0>][<NUM_LIT:3>:]<EOL>if ops_stack[-<NUM_LIT:1>] != end_what:<EOL><INDENT>raise SyntaxError("<STR_LIT>" % end_what)<EOL><DEDENT>ops_stack.pop()<EOL>code.dedent()<EOL><DEDENT>else:<EOL><INDENT>raise SyntaxError("<STR_LIT>" % words[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if tok:<EOL><INDENT>buffered.append("<STR_LIT>" % tok)<EOL><DEDENT><DEDENT><DEDENT>flush_output()<EOL>for var_name in self.all_vars - self.loop_vars:<EOL><INDENT>vars_code.add_line("<STR_LIT>" % (var_name, var_name))<EOL><DEDENT>if ops_stack:<EOL><INDENT>raise SyntaxError("<STR_LIT>" % ops_stack[-<NUM_LIT:1>])<EOL><DEDENT>code.add_line("<STR_LIT>")<EOL>code.dedent()<EOL>self.render_function = code.get_function('<STR_LIT>')<EOL>
Construct a Templite with the given `text`.

        `contexts` are dictionaries of values to use for future renderings.
        These are good for filters and global values.