def parse_template(self, template, **context):
required_blocks = ["<STR_LIT>", "<STR_LIT:body>"]<EOL>optional_blocks = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]<EOL>if self.template_context:<EOL><INDENT>context = dict(self.template_context.items() + context.items())<EOL><DEDENT>blocks = self.template.render_blocks(template, **context)<EOL>for rb in required_blocks:<EOL><INDENT>if rb not in blocks:<EOL><INDENT>raise AttributeError("<STR_LIT>" % (rb, template))<EOL><DEDENT><DEDENT>mail_params = {<EOL>"<STR_LIT>": blocks["<STR_LIT>"].strip(),<EOL>"<STR_LIT:body>": blocks["<STR_LIT:body>"]<EOL>}<EOL>for ob in optional_blocks:<EOL><INDENT>if ob in blocks:<EOL><INDENT>if ob == "<STR_LIT>" and mail_params[ob].lower() not in ["<STR_LIT:html>", "<STR_LIT:text>"]:<EOL><INDENT>continue<EOL><DEDENT>mail_params[ob] = blocks[ob]<EOL><DEDENT><DEDENT>return mail_params<EOL>
To parse a template and return all the blocks