def template(*args, **kwargs):
tpl = args[<NUM_LIT:0>] if args else None<EOL>adapter = kwargs.pop('<STR_LIT>', SimpleTemplate)<EOL>lookup = kwargs.pop('<STR_LIT>', TEMPLATE_PATH)<EOL>tplid = (id(lookup), tpl)<EOL>if tplid not in TEMPLATES or DEBUG:<EOL><INDENT>settings = kwargs.pop('<STR_LIT>', {})<EOL>if isinstance(tpl, adapter):<EOL><INDENT>TEMPLATES[tplid] = tpl<EOL>if settings: TEMPLATES[tplid].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[tplid] = adapter(source=tpl, lookup=lookup, **settings)<EOL><DEDENT>else:<EOL><INDENT>TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings)<EOL><DEDENT><DEDENT>if not TEMPLATES[tplid]:<EOL><INDENT>abort(<NUM_LIT>, '<STR_LIT>' % tpl)<EOL><DEDENT>for dictarg in args[<NUM_LIT:1>:]:<EOL><INDENT>kwargs.update(dictarg)<EOL><DEDENT>return TEMPLATES[tplid].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).