public function render(array $variables = []): string
    {
        // Set the variables with the new variables and this view instance
        $this->variables = array_merge(
            $this->variables,
            $variables,
            ['view' => $this]
        );

        // Render the template
        $template = $this->renderTemplate($this->templatePath);

        // Check if a layout has been set
        if (null === $this->layout) {
            return $template;
        }

        // Begin tracking layout changes for recursive layout
        $this->trackLayoutChanges = true;

        return $this->renderTemplate($this->layoutPath);
    }
public function render(array $variables = []): string
    {
        // Set the variables with the new variables and this view instance
        $this->variables = array_merge(
            $this->variables,
            $variables,
            ['view' => $this]
        );

        // Render the template
        $template = $this->renderTemplate($this->templatePath);

        // Check if a layout has been set
        if (null === $this->layout) {
            return $template;
        }

        // Begin tracking layout changes for recursive layout
        $this->trackLayoutChanges = true;

        return $this->renderTemplate($this->layoutPath);
    }
public function render ( array $ variables = [ ] ) : string { // Set the variables with the new variables and this view instance $ this -> variables = array_merge ( $ this -> variables , $ variables , [ 'view' => $ this ] ) ; // Render the template $ template = $ this -> renderTemplate ( $ this -> templatePath ) ; // Check if a layout has been set if ( null === $ this -> layout ) { return $ template ; } // Begin tracking layout changes for recursive layout $ this -> trackLayoutChanges = true ; return $ this -> renderTemplate ( $ this -> layoutPath ) ; }
Render the templates and view.

@param array $variables [optional] The variables to set

@return string
Render the templates and view .