Renders the provided message (pbj) using a template which is resolved by calling
the "pbjTemplate" method in this trait.

@param Message  $pbj
@param string   $template
@param Response $response
@param string   $format

@return Response
198435
protected function renderPbj(
        Message $pbj,
        string $template = 'page',
        ?Response $response = null,
        string $format = 'html'
    ): Response {
        if (is_callable([$this, 'renderUsingDeviceView'])) {
            return $this->renderUsingDeviceView(
                $this->pbjTemplate($pbj, "{$template}%device_view%", $format), ['pbj' => $pbj], $response
            );
        }

        return $this->render($this->pbjTemplate($pbj, $template, $format), ['pbj' => $pbj], $response);
    }
941603
protected function render(Template $template)
    {
        $presenter = $this->createPresenter($template->getPresenter());

        try {
            $arguments = $this->getArguments($presenter, $template);
            $this->logger->debug($arguments);
            $result = call_user_func_array($presenter, $arguments);
        } catch(Exception $e) {
            if ($this->throwRenderExceptions) {
                throw $e;
            }

            $this->logger->error($e->getMessage() .
                    "\n\nURL: " . URLUtils::fullUrl() .
                    "\n\nTemplate:\n" . print_r($template, true) .
                    (isset($arguments) ? "\n\n$presenter args:\n" . print_r($arguments, true) : '')
                );

            $result = '';
        }

        return $result;
    }
368651
protected function getTemplate($format)
    {
        if (!isset($this->formatFilePaths[$format])) {
            throw new \Exception(sprintf('No format "%s" configured for Snippet export', $format));
        }

        $templatePath = $this->formatFilePaths[$format];

        if (!$this->templating->exists($templatePath)) {
            throw new \Exception(sprintf('No template file "%s" found for Snippet export', $format));
        }

        return $templatePath;
    }
87648
public function render($format = null) {
		// list has its own format
		if ($this->initiator_class == 'list') {
			$format = $this->values['__format'] ?? 'text/html';
		}
		if (!isset($format)) $format = $this->options['input']['__content_type'] ?? 'text/html';
		$content_types_model = new \Object\Form\Model\Content\Types();
		$content_types = $content_types_model->get();
		if (empty($content_types[$format])) $format = 'text/html';
		$model =  new $content_types[$format]['no_form_content_type_model']();
		// special mode for emails
		if ($this->initiator_class == 'email') {
			\HTML::setMode(true);
			$result = $model->render($this);
			\HTML::setMode(false);
			return $result;
		} else {
			return $model->render($this);
		}
	}
915129
public function render($template, array $parameters = null, Response $response = null)
    {
        $parameters = array_merge([
            'request'              => $this->getRequest(),
            'routing'              => $this->routing,
            'flash_bag'            => $this->application->getSession()->getFlashBag(),
        ], $parameters ?: []);

        return $this->application->getRenderer()->partial($template, $parameters);
    }
164591
protected function nonXhrJavascriptResponse($request, $response)
    {
        return ($request->getFormat($response->headers->get('Content-Type')) === 'js' &&
            ! $request->ajax()
        );
    }
764188
protected function render(Response $response, $template, array $params = [])
    {
        return $this->container['twig']->render($response, $template, $params);
    }
999752
async function renderObj(nj, myVars, templateVars) {
  return JSON.parse(await render(nj, JSON.stringify(myVars), templateVars));
}
872055
public function render(string $templateID, string $language, \Swift_Mime_SimpleMessage &$message)
    {
        // Find Template
        $template = $this->entityManager
            ->getRepository(MailTemplate::class)
            ->findOneBy(['templateId' => $templateID, 'status' => true, 'language' => $language]);

        if ((null === $template) && ($language !== $this->defaultLanguage)) {
            return $this->render($templateID, $this->defaultLanguage, $message);
        }

        // Render Template
        if (null !== $template) {
            // Render Body
            try {
                $message->setBody(
                    $this->twig->createTemplate($template->getTemplate())->render(unserialize($message->getBody())),
                    $message->getContentType(),
                    $message->getCharset());
            } catch (\Exception $e) {
            }

            // Set Header
            if (!empty($template->getFromName()) && !empty($template->getFromEmail())) {
                $message->setFrom($template->getFromEmail(), $template->getFromName());
            }

            // Set Subject
            if (!empty($template->getSubject())) {
                $message->setSubject($template->getSubject());
            }

            return true;
        }

        return false;
    }
657509
public function render($view, array $parameters = [], Response $response = null)
    {
        return $this->templating->renderResponse($view, $parameters, $response);
    }
873730
public function getAjaxec($response, $chain = null)
    {
        if (is_array($response) && $response[0] instanceof View) {
            $response = $response[0];
        }

        if ($response instanceof View) {
            $response = new jsExpression('$([html]).modal("show")', [
                        'html' => '<div class="ui fullscreen modal"> <i class="close icon"></i>  <div class="content"> '.
                        $response->render()
                        .' </div> </div>',
                    ]);
        }

        if ($response === $chain) {
            $response = null;
        }

        $actions = [];

        if ($chain && $chain->_chain) {
            $actions[] = $chain;
        }

        $response = $this->flatternArray($response);

        foreach ($response as $r) {
            if (is_string($r)) {
                $actions[] = new jsExpression('alert([])', [$r]);
            } elseif ($r instanceof jsExpressionable) {
                $actions[] = $r;
            } elseif ($r === null) {
                continue;
            } else {
                throw new Exception(['Incorrect callback. Must be string or action.', 'r' => $r]);
            }
        }

        $ajaxec = implode(";\n", array_map(function (jsExpressionable $r) {
            return $r->jsRender();
        }, $actions));

        return $ajaxec;
    }
784391
public function renderWithExtraParams($view, array $parameters = [], Response $response = null)
    {
        if (!$this->isXmlHttpRequest()) {
            $parameters['breadcrumbs_builder'] = $this->get('sonata.admin.breadcrumbs_builder');
        }
        $parameters['admin'] = $parameters['admin'] ??
            $this->admin;

        $parameters['base_template'] = $parameters['base_template'] ??
            $this->getBaseTemplate();

        $parameters['admin_pool'] = $this->get('sonata.admin.pool');

        //NEXT_MAJOR: Remove method alias and use $this->render() directly.
        return $this->originalRender($view, $parameters, $response);
    }
2680
public function renderJsonAction($view, $layout): ServiceResponse
    {
        $layout = $this->getLayout($layout);
        if ($this->RequestHandler) {
            // Make sure the view is rendered as HTML, even if it is an AJAX request
            // jsonActionResponse() will make sure the JSON response is rendered correctly
            $this->RequestHandler->renderAs($this, 'ajax');
            $this->RequestHandler->ext = 'html';
        }
        $response = parent::render($view, $layout);

        return $this->jsonActionResponse($response);
    }
186296
public function renderTemplate(Request $request, Response $response, $template, $status = null)
    {
        $response->getBody()->write($this->fetchTemplate($request, $template));

        if ($status) {
            $response = $response->withStatus($status);
        }

        return $response;
    }
1015800
protected function renderTemplate(PdfTemplateTransfer $template)
    {
        $templateType = $template->getType();
        if ($templateType === PdfConfig::TEMPLATE_TYPE_RAW_HTML) {
            return $template->getRaw();
        }

        if (!array_key_exists($templateType, $this->templateRenderer)) {
            throw new TemplateRendererNotFoundException(
                sprintf('Template-renderer %s does not exist.', $templateType)
            );
        }

        $templateRenderer = $this->templateRenderer[$templateType];

        return $templateRenderer->render($template);
    }
1056814
protected function renderResponse($view, array $parameters = array(), Response $response = null)
    {
        return $this->get('templating')->renderResponse($view, $parameters, $response);
    }
1043408
public function format(array $response)
    {
        $car = '<br />';
        $format = '';
        foreach ($response as $page) {
            $format .= '<div class="page"><span class="title">'
            . ApiTools::safeString($page->getTitle()) . '</span>'
            .$car . 'pageid: <span class="pageid">' . $page->getPageid() . '</span>'
            .$car . 'displaytitle: ' . ApiTools::safeString($page->getDisplaytitle())
            .$car . 'page_image_free: ' . $page->getPageImageFree()
            .$car . 'wikibase_item: ' . $page->getWikibaseItem()
            .$car . 'disambiguation: ' . $page->getDisambiguation()
            .$car . 'defaultsort: ' . $page->getDefaultsort()
            .'</div>';
        }
        return $format;
    }