def template(*args, **kwargs):
tpl = args[<NUM_LIT:0>] if args else None<EOL>template_adapter = kwargs.pop('<STR_LIT>', SimpleTemplate)<EOL>if tpl not in TEMPLATES or DEBUG:<EOL><INDENT>settings = kwargs.pop('<STR_LIT>', {})<EOL>lookup = kwargs.pop('<STR_LIT>', TEMPLATE_PATH)<EOL>if isinstance(tpl, template_adapter):<EOL><INDENT>TEMPLATES[tpl] = tpl<EOL>if settings: TEMPLATES[tpl].prepare(**settings)<EOL><DEDENT>elif "<STR_LIT:\n>" in tpl or "<STR_LIT:{>" in tpl or "<STR_LIT:%>" in tpl or '<STR_LIT:$>' in tpl:<EOL><INDENT>TEMPLATES[tpl] = template_adapter(source=tpl, lookup=lookup, **settings)<EOL><DEDENT>else:<EOL><INDENT>TEMPLATES[tpl] = template_adapter(name=tpl, lookup=lookup, **settings)<EOL><DEDENT><DEDENT>if not TEMPLATES[tpl]:<EOL><INDENT>abort(<NUM_LIT>, '<STR_LIT>' % tpl)<EOL><DEDENT>for dictarg in args[<NUM_LIT:1>:]: kwargs.update(dictarg)<EOL>return TEMPLATES[tpl].render(kwargs)<EOL>
Get a rendered template as a string iterator.
You can use a name, a filename or a template string as first parameter.
Template rendering arguments can be passed as dictionaries
or directly (as keyword arguments).