'Render the specified template and context. Cache the template object
in render_context to avoid reparsing and loading when used in a for
loop.'

def render(self, context):

    (resolved_args, resolved_kwargs) = self.get_resolved_arguments(context)
    _dict = self.func(*resolved_args, **resolved_kwargs)
    t = context.render_context.get(self)
    if (t is None):
        if isinstance(self.filename, Template):
            t = self.filename
        elif isinstance(getattr(self.filename, 'template', None), Template):
            t = self.filename.template
        elif ((not isinstance(self.filename, str)) and is_iterable(self.filename)):
            t = context.template.engine.select_template(self.filename)
        else:
            t = context.template.engine.get_template(self.filename)
        context.render_context[self] = t
    new_context = context.new(_dict)
    csrf_token = context.get('csrf_token')
    if (csrf_token is not None):
        new_context['csrf_token'] = csrf_token
    return t.render(new_context)
