def _render(template=None, filepath=None, context=None, at_paths=None,<EOL>at_encoding=anytemplate.compat.ENCODING, at_engine=None,<EOL>at_ask_missing=False, at_cls_args=None, _at_usr_tmpl=None,<EOL>**kwargs):
ecls = find_engine(filepath, at_engine)<EOL>LOGGER.debug("<STR_LIT>", ecls.name())<EOL>engine = ecls() if at_cls_args is None else ecls(**at_cls_args)<EOL>at_paths = anytemplate.utils.mk_template_paths(filepath, at_paths)<EOL>if filepath is None:<EOL><INDENT>(render_fn, target) = (engine.renders, template)<EOL><DEDENT>else:<EOL><INDENT>(render_fn, target) = (engine.render, filepath)<EOL><DEDENT>try:<EOL><INDENT>return render_fn(target, context=context, at_paths=at_paths,<EOL>at_encoding=at_encoding, **kwargs)<EOL><DEDENT>except TemplateNotFound as exc:<EOL><INDENT>LOGGER.warning("<STR_LIT>", at_paths)<EOL>if not at_ask_missing:<EOL><INDENT>raise TemplateNotFound(str(exc))<EOL><DEDENT>if _at_usr_tmpl is None:<EOL><INDENT>_at_usr_tmpl = anytemplate.compat.raw_input(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % ("<STR_LIT:U+002CU+0020>" + filepath if template is None else '<STR_LIT>')<EOL>).strip()<EOL><DEDENT>usr_tmpl = anytemplate.utils.normpath(_at_usr_tmpl)<EOL>if template is None:<EOL><INDENT>LOGGER.debug("<STR_LIT>", usr_tmpl, filepath)<EOL>target = usr_tmpl<EOL><DEDENT>return render_fn(target, context=context,<EOL>at_paths=(at_paths + [os.path.dirname(usr_tmpl)]),<EOL>at_encoding=at_encoding, **kwargs)<EOL><DEDENT>except Exception as exc:<EOL><INDENT>raise CompileError("<STR_LIT>" % (exc, target[:<NUM_LIT:200>]))<EOL><DEDENT>
Compile and render given template string and return the result string.

:param template: Template content string or None
:param filepath: Template file path or None
:param context: A dict or dict-like object to instantiate given
    template file
:param at_paths: Template search paths
:param at_encoding: Template encoding
:param at_engine: Specify the name of template engine to use explicitly or
    None to find it automatically anyhow.
:param at_cls_args: Arguments passed to instantiate template engine class
:param _at_usr_tmpl: Template file of path will be given by user later;
    this file will be used just for testing purpose.
:param kwargs: Keyword arguments passed to the template engine to
    render templates with specific features enabled.

:return: Rendered string