Renders template with previous set data.

@param Request  $request
@param Response $response
@param string   $template The template to render
@param int      $status   [optional] Response status code

@return Response
@throws Exception
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;
    }
372774
public function respond($response, $status, $headers, $options)
    {
        switch ($this->getRequestFormat()) {
            case 'html' :
            case 'text/html' :
                return Response::make($response, $status, $headers, $options)
                    ->header('Content-Type', 'text/html');
            default :
                // whether 'Content-Type' is NULL or equal to anything such as 'application/json' response will be JSON
                return Response::json($response, $status, $headers, $options);
        }
    }
518536
public JsonResponse getTemplate(String template) throws IOException {
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(Template.PARAM_TEMPLATE, template);
        return apiGet(ApiAction.template, data);
    }
265971
public function render(?Request $request = null): Response {
        $request = self::validateRequest($request);

        $translator = $this->translatorProvider->getPreferredTranslator(
            $request->getLanguages(),
            $this->config['default_language']
        );

        $response = new Response();

        $response->setContent($this->templateRenderer->render(
            $this->config['template_name'],
            array_merge($translator->getTranslations(), [
                'lang' => $translator->getLanguage(),
                'charset' => $this->config['charset']
            ])
        )."\n<!-- Powered by progminer/maintenance-screen (https://packagist.org/packages/progminer/maintenance-screen) -->\n");
        $response->headers->set('Content-Language', $translator->translate('lang'));

        return $response;
    }
605336
private function displayError(Request $request,Response $response){
        $exception=$response->getContent();

        $data=array(
            'statusCode'=>$response->getStatusCode()
        ,'message'=>$exception->getMessage()
        ,'exception'=>get_class($exception)
        ,'file'=>$exception->getFile()
        ,'line'=>$exception->getLine()
        );

        if($this->environment->isDebug()){
            echo $this->twig->render('error.twig', $data);
        }
        else{
            echo $this->twig->render($response->getStatusCode().'.twig');
        }
    }
524529
public function renderRequest(Request $request, Response $response, RenderingContext $renderingContext)
    {
        $contentObjectRenderer = new ContentObjectRenderer();
        $content = $contentObjectRenderer->cObjGetSingle('RECORDS', $this->resolveRenderingConfiguration($request, $renderingContext));
        $response->setContent($content);
    }
18643
final public function render($template=null, $data=null)
    {
        $renderType = $this->getRenderType();
        switch ($renderType) {
            case 'json':
                $this->renderJson($data);
                break;
            case 'xml':
                $this->renderXml($data);
                break;
            case 'html':
                $this->renderHtml($template, $data);
                break;
            default:
                $string = print_r($data, true);
                $this->renderText($string);
                break;
        }
        
        return $this->response;
    }
426619
public function update(TemplateRequest $request, $template)
    {
        try {
            $template = $request->template;
            $path = theme_path('views').$template;
            $content = $request->content;

            // Notify if file was not changed.
            if (\File::exists($path) and \File::get($path) == $content) {
                return response()->json([
                    'status' => false,
                    'message' => sprintf(__('msg.not_updated'), $template),
                ], 200);
            }

            \File::put($path, $content, true);

            return response()->json([
                'status' => true,
                'message' => sprintf(__('msg.updated'), $template),
                'file' => [
                    'size' => formatBytes(\File::size($path)),
                    'modified' => strftime('%Y-%m-%d %H:%M', \File::lastModified($path))
                ]
            ], 200);

        } catch (ValidationException $e) {
            $message = $e->validator->errors()->first();
            return response()->json(['status' => false, 'message' => $message], 200);
        } catch (\Exception $e) {
            $message = $e->getMessage();
            return response()->json(['status' => false, 'message' => $message], 404 );
        }
    }
1146406
public function render($request, Exception $exception)
    {
        // Convert all non-http exceptions to a proper 500 http exception
        // if we don't do this exceptions are shown as a default template
        // instead of our own view in resources/views/errors/500.blade.php
        if ($this->shouldReport($exception) && !$this->isHttpException($exception) && !config('app.debug')) {
            $exception = new HttpException(500, 'Whoops!');
        }

        return parent::render($request, $exception);
    }
899512
public function editorViewAction(Request $request, Template $template)
    {
        $request->request->set('blockMode', 'manage');
        return $this->render($template->getView(), ['block' => $template]);
    }
1245190
public function viewAction(Request $request): Response
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);

        $this->isGrantedOr403($configuration, ResourceActions::SHOW);

        /** @var DefinedTranslationInterface|TemplateAwareInterface|ResourceInterface $resource */
        $resource = $this->findOr404($configuration);

        $this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $resource);

        $view = View::create($resource);

        if ($configuration->isHtmlRequest()) {
            $template = $resource->getTemplate();

            if ($template) {
                $tpl = $resource->getTemplateName();
                $options = $template->getOptions();
            } else {
                $tpl = $configuration->getTemplate(ResourceActions::SHOW.'.html');
                $options = [];
            }

            $this->addTranslations($resource);

            $view
                ->setTemplate($tpl)
                ->setTemplateVar($this->metadata->getName())
                ->setData(
                    [
                        'configuration' => $configuration,
                        'metadata' => $this->metadata,
                        'resource' => $resource,
                        'tpl' => ['options' => $options],
                        $this->metadata->getName() => $resource,
                    ]
                );
        }

        return $this->viewHandler->handle($configuration, $view);
    }
1225837
public function index($page = null, $status = null)
    {
        $url = 'templates.json';

        $templates = $this->client->get($url, [
            'query' => [
                'status' => $status,
                'page' => $page,
            ],
        ]);

        return $this->indexResponse($templates, Template::class);
    }
861210
public function render($template, $parameters = [])
    {
        if (count($parameters) < 1) {
            $parameters = null;
        }
        echo $this->smarty->fetch($template, $parameters);
    }
972104
public function render($request, Exception $exception)
    {
        $exception = $this->prepareException($exception);

        if ($exception instanceof HttpResponseException) {
            return $exception->getResponse();
        } elseif ($exception instanceof AuthenticationException) {
            return $this->unauthenticated($request, $exception);
        } elseif ($exception instanceof ValidationException) {
            return $this->convertValidationExceptionToResponse($exception, $request);
        } elseif ($this->isHttpException($exception) && $this->customErrorHtmlTemplateExists($exception)) {
            return $this->prepareResponse($request, $exception);
        }

        $flattened = FlattenException::create($exception);

        $code = $flattened->getStatusCode();
        $headers = $flattened->getHeaders();
        $response = $this->getContent($exception, $code, $request);

        // If it's already a response, return that.
        if (!$response instanceof BaseResponse) {
            $response = new Response($this->getContent($exception, $code, $request), $code, $headers);
        }

        return $response;
    }
1269576
protected function render($template, $data = array()) {
        Router::getInstance()->render($template, $data);
        $response = ob_get_contents();
        return ob_get_clean();
    }
843128
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $collection = $this->container->get('routing');

        $_routes = $collection->all();

        $routes = array();

        foreach ($_routes as $routeName => $route) {
            $defaults = $route->getDefaults();
            $requirements = $route->getRequirements();

            $controller = isset($defaults['_controller']) ? $defaults['_controller'] : 'unknown';

            if (is_object($controller)) {
                $controller = get_class($controller);
            } elseif ($this->container->hasDefinition($controller)) {
                $controllerDefinition = $this->container->findDefinition($controller);
                /*  @var $controllerDefinition \Symfony\Component\DependencyInjection\Definition */
                $controller = '@'.$controller.' - '.$controllerDefinition->getClass();
            }

            $routes[$routeName] = array(
                'name' => $routeName,
                'pattern' => $route->getPattern(),
                'controller' => $controller,
                'method' => isset($requirements['_method']) ? $requirements['_method'] : 'ANY',
                'action' => isset($defaults['_action']) ? $defaults['_action'] : 'n/a',
            );
        }
        ksort($routes);
        $this->data['matchRoute'] = $request->attributes->get('_route');
        $this->data['routes'] = $routes;

        $this->data['resources'] = array();

        // get BB route sources
        foreach ($this->container->get('bbapp')->getConfig()->getDebugData() as $configFile => $configData) {
            if ('route.yml' == basename($configFile)) {
                $this->data['resources'][$configFile] = $configData;
            } elseif (array_key_exists('route', $configData)) {
                $this->data['resources'][$configFile] = $configData['route'];
            }
        }

        // get bundle route sources
        foreach ($this->container->get('bbapp')->getBundles() as $bundle) {
            foreach ($bundle->getConfig()->getDebugData() as $configFile => $configData) {
                if ('route.yml' == basename($configFile)) {
                    $this->data['resources'][$configFile] = $configData;
                } elseif (array_key_exists('route', $configData)) {
                    $this->data['resources'][$configFile] = $configData['route'];
                }
            }
        }
    }
648733
protected function wrapResponse(Request $request, JsonResponse $response)
    {
        switch ($request->query->get(self::PARAMETER_WRAPPER)) {
            case self::WRAPPER_POST_MESSAGE:
                $response->setContent(
                    sprintf(
                        $this->getPostMessageTemplate(),
                        $response->getContent(),
                        $this->getCallbackFromRequest($request),
                        $this->getPostMessageOrigin()
                    )
                )->headers->set('Content-Type', 'text/html');
                break;
            default:
                $response->setCallback(
                    $request->query->get(self::PARAMETER_CALLBACK)
                );
                break;
        }
    }