Render response

@param Context $context
@return Context
779106
protected function render(Context $context)
    {
        $this->logger->debug('kernel.process.render: render Response');

        // resolve output format
        if($context->response->raw) {

            // template
            if($template = $context->logic->html) {

                // render template
                $vars = $context->response->content;
                $vars = is_array($vars) ? $vars : (array)$vars;
                $content = $this->templater->render($template, $vars);

                // set html response
                $context->response = new Response\Html($content, $context->response->code, $context->response->headers);
                $this->logger->debug('kernel.process.render: template "' . $template . '" compiled');
            }
            // json
            elseif($context->logic->render = 'json') {
                $context->response = new Response\Json($context->response->content, $context->response->code, $context->response->headers);
                $this->logger->debug('kernel.process.render: json response generated');
            }

            // remove auto-generated flag
            $context->response->raw = false;
        }
        // render template
        elseif($context->response instanceof Response\Template) {
            $context->response->content = $this->templater->render($context->response->template, $context->response->vars);
        }
        // render redirect
        elseif($context->response instanceof Response\Redirect and $context->response->uri[0] == '/') {
            $context->response->uri = $context->request->uri->make($context->response->uri);
        }

        return $context;
    }
1310638
protected function _afterRender(ViewContextInterface $context)
    {
        foreach ($this->getDecorators() as $decorator)
        {
            //Set the content to allow it to be decorated
            $this->setContent($context->result);

            //A fully qualified template path is required
            $layout = $this->qualifyLayout($decorator);

            //Unpack the data (first level only)
            $data = $context->data->toArray();

            $context->result = $this->getTemplate()
                ->setParameters($context->parameters)
                ->render($layout, $data);
        }
    }
1015708
public function render($context)
    {
        if ($this->place || $this->place == self::RESET_CONTEXT) {
            return sprintf('<img src="%s" alt="%s" />', $this->path, $this->alt);
        } elseif ($this->place == self::PRE_CONTEXT) {
            return sprintf('<img src="%s" alt="%s" />', $this->path, $this->alt) . $context;
        } else {
            return $context . sprintf('<img src="%s" alt="%s" />', $this->path, $this->alt);
        }
    }
178042
public function renderUserElementMap(array &$context)
	{
		$map = $this->renderer->getElementMap($context['user']['id'], Craft::$app->getSites()->getPrimarySite()->id);
		return $this->renderMap($map);
	}
992108
public function render($context)
    {
        $values = array();
        if (count($this->vars)) {
            $actualRow = $this->getCell()->getActualRow();
            foreach ($this->vars as $var) {
                $values[] = $actualRow[$var];
            }
        }
        $url = vsprintf($this->url, $values);
        return sprintf('<a  href="%s">%s</a>', $url, $context);
    }
292218
def render_to_response(self, context, **response_kwargs):
        
        response_kwargs['content_type'] = 'application/json'
        return self.response_class(
            self.convert_context_to_json(context),
            **response_kwargs
        )
749116
protected function _render($context = null)
    {
        if (is_null($context)) {
            $context = [];
        }

        return $this->_replaceTokens($this->_getPlaceholderTemplate(), $context, $this->_getTokenStart(), $this->_getTokenEnd(), $this->_getDefaultPlaceholderValue());
    }
1010980
public function render($context = [])
    {
        if ($element = $this->getElement()) {
            $class = $element->getAttribute('class', false);
            $class .= $class
                ? ' form-control'
                : 'form-control';
            $this->getElement()->setAttribute('class', $class);
        }

        return parent::render($context);
    }
919529
public function buffer(Context $context): Promise
    {
        return $context->task(function (Context $context) {
            $buffer = '';
            
            try {
                while (null !== ($chunk = yield $this->read($context, 0xFFFF))) {
                    $buffer .= $chunk;
                }
            } finally {
                $this->close();
            }
            
            return $buffer;
        });
    }
80570
protected function render(IComponentResponse $response, IContext $context)
    {
        $content = $response->getContent();

        if ($content instanceof IDisplayModel) {
            $view = $this->getView();

            if ($view instanceof IContextAware) {
                $view->setContext($context);
            }

            try {
                $content = $view->render($content->getTemplate(), $content->getVariables());
            } catch (\Exception $e) {
                throw new RuntimeException(
                    $this->translate(
                        'Cannot render template "{template}".',
                        [
                            'template' => $content->getTemplate()
                        ]
                    ),
                    0,
                    $e
                );
            }

            $response->setContent($content);

            if ($view instanceof IContextAware) {
                $view->clearContext();
            }
        }

        return $response;
    }
118405
protected function _actionForward(AnCommandContext $context)
    {
        $response = $this->getController()->getResponse();

        if (! $response->getContent()) {
            if (in_array($response->getStatusCode(), array(201, 205))) {
                $view = $this->getController()->getIdentifier()->name;
                $response->setContent($this->getController()->view($view)->execute('display', $context));

                if ($response->getStatusCode() == 205) {
                    $response->setStatus(200);
                }
            }
        }

        return $context->result;
    }
651689
public function proceed(Context $context)
    {
        $context = $this->route($context);
        $context = $this->resolve($context);
        $context = $this->guard($context);
        $context = $this->execute($context);
        $context = $this->render($context);

        return $context;
    }
321886
protected function render_context_header(context_header $contextheader) {

        $showheader = empty($this->page->layout_options['nocontextheader']);
        if (!$showheader) {
            return '';
        }

        // All the html stuff goes here.
        $html = html_writer::start_div('page-context-header');

        // Image data.
        if (isset($contextheader->imagedata)) {
            // Header specific image.
            $html .= html_writer::div($contextheader->imagedata, 'page-header-image');
        }

        // Headings.
        if (!isset($contextheader->heading)) {
            $headings = $this->heading($this->page->heading, $contextheader->headinglevel);
        } else {
            $headings = $this->heading($contextheader->heading, $contextheader->headinglevel);
        }

        $html .= html_writer::tag('div', $headings, array('class' => 'page-header-headings'));

        // Buttons.
        if (isset($contextheader->additionalbuttons)) {
            $html .= html_writer::start_div('btn-group header-button-group');
            foreach ($contextheader->additionalbuttons as $button) {
                if (!isset($button->page)) {
                    // Include js for messaging.
                    if ($button['buttontype'] === 'togglecontact') {
                        \core_message\helper::togglecontact_requirejs();
                    }
                    if ($button['buttontype'] === 'message') {
                        \core_message\helper::messageuser_requirejs();
                    }
                    $image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
                        'class' => 'iconsmall',
                        'role' => 'presentation'
                    ));
                    $image .= html_writer::span($button['title'], 'header-button-title');
                } else {
                    $image = html_writer::empty_tag('img', array(
                        'src' => $button['formattedimage'],
                        'role' => 'presentation'
                    ));
                }
                $html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);
            }
            $html .= html_writer::end_div();
        }
        $html .= html_writer::end_div();

        return $html;
    }
827589
def render_to_response(self, context, **response_kwargs):
        
        if self.request.is_ajax():
            data = {
                "content": render_to_string(
                    self.get_template_names(), context, request=self.request)
            }
            return JsonResponse(data)
        if settings.DEBUG:
            return super(PartialAjaxMixin, self).render_to_response(
                context, **response_kwargs)
        raise Http404()
1205527
public function render($context = [])
    {
        if ($this->getElement()->hasAttribute('value')) {
            $this->getElement()->getAttributes()->remove('value');
        }
        return parent::render($context);
    }
549719
public function renderCategoryElementMap(array &$context)
	{
		$map = $this->renderer->getElementMap($context['category']['id'], $context['site']['id']);
		return $this->renderMap($map);
	}
920660
public function render($context)
    {
        if (count($this->attr) > 0) {
            foreach ($this->attr as $name => $value) {
                $this->getCell()->addVarAttr($name, $value);
            }
        }
        return $context;
    }