Render a html template.

@param string $path
@param array $data
@param integer $status

@return static
766871
public function template($path, $data = [], $status = HttpMessage::HTTP_OK)
    {
        $tempFile = $path . '.php';
        if (! is_file($tempFile)) {
            throw new \RuntimeException('Could not find the template file <' . $path . '>');
        }
        ob_start();
        extract($data);
        include($path . '.php');
        $content = ob_get_clean();
        return $this->html($content, $status);
    }
451118
protected function prepareHttpResponse($data, $status, $exception = null)
	{
	    
	    $error = $this->getRequest()->getHeader(
	            self::HEADER_ERRORS, 
	            self::HEADER_ERRORS_DEFAULT);
	    
	    $forceHtmlContentType = $this->getRequest()->getHeader(
	            self::HEADER_FORCE_CONTENT_HTML,
	            false);
	    
	    if ($error instanceof HeaderInterface) {
	        $error = $error->getFieldValue();
	    }
	    
	    $response = $this->getResponse();
	    
	    $headers = array(
	    	'Cache-Control' => 'no-cache, must-revalidate',
	        'Pragma' 		=> 'no-cache',
	    	'Expires' 		=> '2000-01-01 00:00:00',
            'Content-Type'  => 'application/json',
	    );
	    
	    if ($forceHtmlContentType) {
	        $headers['Content-Type'] = 'text/html';
	    }

	    $response->getHeaders()->addHeaders($headers);
	    
	    // update response status code
	    $response->setStatusCode(
        	$status
        );
	    
	    // update reason phrase
	    if($exception){
	        
	        if ($exception instanceof ServiceException) {
	            $message = $exception->getMessage();
	        } else {
	            $message = 'Unknown exception';
	        }
	        
	    	$response->setReasonPhrase(
    	        $message
	    	);
	    }
	    
	    if ($data instanceof \Zend\Http\Response) {
	        
    	    // Attach custom stream response sender listener
	        // to send the stream to output buffer in chunks
	        if ($data instanceof Stream) {
	            $sendReponseListener = $this->getServiceLocator()->get('SendResponseListener');
	            $sendReponseListener->getEventManager()->attach(
	                    SendResponseEvent::EVENT_SEND_RESPONSE,
	                    new StreamResponseSender(),
	                    10000);
	        }
	        
	        return $data;
	    } else {
	        
	        $responseModel = array(
                'd' => $data
	        );
	        
	        // Append exception data
	        if ($exception) {
	            
	            if ($error == self::HEADER_ERRORS_VERBOSE && $exception instanceof ServiceException) {
	                $responseModel['e'] = array(
                        'm' => $exception->getRawMessage(),
                        'c' => $exception->getCode(),
                        'a' => $exception->getVars()
	                );
	                
	            } else {
	                $responseModel['e'] = array(
                        'm' => $response->getReasonPhrase(),
                        'c' => $exception->getCode(),
	                );
	            }
	        }
	        
	        try {
	            $response->setContent(JsonEncoder::encode($responseModel, true));
	        } catch (Exception $e) {
	            
	            if ($e instanceof RecursionException) {
	                $message = self::CYCLIC_DATA_ERROR;
	            } else {
	                $message = $e->getMessage();
	            }
	            
	            $response->setReasonPhrase(
                    $message
	            );
	            
	            $response->setStatusCode(
                    self::STATUS_UNKNOWN_EXCEPTION
	            );
	            
	            $response->setContent(JsonEncoder::encode([
                    'd' => null,
                    'e' => [
	                   'm' => $message,
	                   'c' => $e->getCode()
	               ]
	            ], true));
	        }
	        
	        return $response;
	    }
	}
10723
public function render($template, $data = array()) {
		if(!is_null($this->layout) && $this->enabled === TRUE) { // Render the layout!!
			$this->setLayoutData('content', parent::render($template, array_merge($this->layoutData, (array)$data)));
			$this->setLayoutData('js', $this->jsAssets->render());
			$this->setLayoutData('css', $this->cssAssets->render());
			$this->setLayoutData('title', $this->titleParts->render());

			return parent::render($this->layout, $this->layoutData);
		} else {
			return parent::render($template, $data);
		}
	}
482302
protected function json(array $data = [], string $status = Response::HTTP_OK): JsonResponse
    {
        $headers = $this->getResponse()->headers->all();

        $serializedData = [];

        foreach ($data as $key => $item) {
            if (is_array($item) && is_object($item[0])) {
                $serializedData[$key] = EntityNormalizer::normalize($item);

                unset($data[$key]);
            }

            if (is_object($item)) {
                $serializedData[$key] = EntityNormalizer::normalize([$item])[0];

                unset($data[$key]);
            }
        }

        $serializedData = array_merge($serializedData, $data);

        return new JsonResponse($serializedData, $status, $headers);
    }
20290
public function render($name, array $data = [])
    {
        
        //$templatePath = $this->manager->pathByName($name);
        $template = $this->twig->load($name);
        return $template->render($data);
    }
284283
public static function render($template = '', $data = [])
    {
        $templatesPath = realpath(__DIR__ . '/../templates');
        $loader        = new \Twig_Loader_Filesystem($templatesPath);
        /** @var object $twig */
        $twig         = new \Twig_Environment($loader);
        $templateFile = $template . '.html';

        return $twig->render($templateFile, $data);
    }
877465
public function makeView(string $path, array $data = [])
	{
		$cached = $this->isCached($path);
		$this->persist($cached, $data);
	}
314643
public function get($path, array $data = [])
    {
        $name = array_search($path, $this->finder->getViews());

        return $this->twig->render($this->parseFileName($name).$this->extension, $data);
    }
456748
public function renderizate($path, $file, $data = null)
    {
        $file = $path . $file . '.php';

        if ($data) {
            self::$data[self::setHash($file)] = $data;
        }

        require_once $file;

        return true;
    }
466159
public function html($data, $status = HttpMessage::HTTP_OK)
    {
        $this->withStatusCode($status)
            ->withHeader('content-type', 'text/html')
            ->getBody()->write((string)$data);
        return $this;
    }
909995
public function composeHtml(array $data = [], int $status = 200, array $config = []): SymfonyResponse
    {
        if (\is_null($view = $config['view'])) {
            throw new InvalidArgumentException('Missing [$view].');
        }

        return Response::make($this->convertToViewable($view, $data, $config), $status);
    }
540188
public function template($template, $data = [])
    {
        $templatePath = self::$instance->app->findTemplate($template);
        echo self::$instance->renderTemplate($templatePath, $data);
    }
809619
public function render(array $data = [], string $path = 'gridView', array $mergeData = []): string
    {
        if (request()->ajax() || request()->wantsJson()) {
            $path = $path === 'gridView' ? 'part.grid' : $path;
        }

        return static::view($path, $data, $mergeData)->render();
    }
996547
public function render($template, $data = array(), $status = null)
    {
        if (!is_null($status) && headers_sent() === false) {
            header($this->container->getResponse()->_convert_status($status));
        }
        $this->container->getView()->display($template, $data);
    }
910151
public static function view(string $path, array $data = [], bool $return = false)
  {
    $data = array_merge(GlobalVariables::get(), $data);

    if ($return) return self::$viewComponent->make($path, $data);

    $view = new View;

    $view->compiled = self::$viewComponent->make($path, $data);

    return $view;
  }
507647
public function renderPage($data, $status = 200)
    {
        $data["stylesheets"] = ["css/style.css"];

        // Add common header, navbar and footer
        //$this->view->add("default1/header", [], "header");
        //$this->view->add("default1/navbar", [], "navbar");
        //$this->view->add("default1/footer", [], "footer");

        // Add layout, render it, add to response and send.
        $this->view->add("default1/layout", $data, "layout");
        $body = $this->view->renderBuffered("layout");
        $this->response->setBody($body)
                       ->send($status);
        exit;
    }
1220627
public function get($path, array $data = array())
    {
        // Instance Twig compiler.
        $twigCompiler = new TwigCompiler($this->app['config'], $this->app['view']);

        return $twigCompiler->render($path, $data);
    }