src/MVC/View.php
public function render($file, $vars = null) 
    {
        $template = '';

        if (is_null($this->templatesPath)) {
            throw new \LogicException('Variable "templatesPath" can\'t be NULL.');
        } else if (is_string($this->templatesPath) && !file_exists($this->templatesPath)) {
            throw new \LogicException(sprintf('Folder "%s" don\'t exists.', $this->templatesPath));
        } else if (is_array($this->templatesPath)) {
            foreach ($this->templatesPath as $folderPath) {
                if (file_exists($template = "$folderPath/{$file}")) {
                    break;
                }
            }
        }
        
        if (!$template) {
            $template = "$this->templatesPath/{$file}";
        }
        
        if(!file_exists($template)){
           throw new \LogicException(sprintf('View "%s" don\'t exists.', $template));
        }
        
        if (is_array($vars)) {
            extract($vars);
            foreach ($vars as $key => $value) {
                $key = $value;
            }
        }        
        
        ob_start();
        require $template;
        return ob_get_clean();
    }
public function render($file, $vars = null) 
    {
        $template = '';

        if (is_null($this->templatesPath)) {
            throw new \LogicException('Variable "templatesPath" can\'t be NULL.');
        } else if (is_string($this->templatesPath) && !file_exists($this->templatesPath)) {
            throw new \LogicException(sprintf('Folder "%s" don\'t exists.', $this->templatesPath));
        } else if (is_array($this->templatesPath)) {
            foreach ($this->templatesPath as $folderPath) {
                if (file_exists($template = "$folderPath/{$file}")) {
                    break;
                }
            }
        }
        
        if (!$template) {
            $template = "$this->templatesPath/{$file}";
        }
        
        if(!file_exists($template)){
           throw new \LogicException(sprintf('View "%s" don\'t exists.', $template));
        }
        
        if (is_array($vars)) {
            extract($vars);
            foreach ($vars as $key => $value) {
                $key = $value;
            }
        }        
        
        ob_start();
        require $template;
        return ob_get_clean();
    }
public function render ( $ file , $ vars = null ) { $ template = '' ; if ( is_null ( $ this -> templatesPath ) ) { throw new \ LogicException ( 'Variable "templatesPath" can\'t be NULL.' ) ; } else if ( is_string ( $ this -> templatesPath ) && ! file_exists ( $ this -> templatesPath ) ) { throw new \ LogicException ( sprintf ( 'Folder "%s" don\'t exists.' , $ this -> templatesPath ) ) ; } else if ( is_array ( $ this -> templatesPath ) ) { foreach ( $ this -> templatesPath as $ folderPath ) { if ( file_exists ( $ template = "$folderPath/{$file}" ) ) { break ; } } } if ( ! $ template ) { $ template = "$this->templatesPath/{$file}" ; } if ( ! file_exists ( $ template ) ) { throw new \ LogicException ( sprintf ( 'View "%s" don\'t exists.' , $ template ) ) ; } if ( is_array ( $ vars ) ) { extract ( $ vars ) ; foreach ( $ vars as $ key => $ value ) { $ key = $ value ; } } ob_start ( ) ; require $ template ; return ob_get_clean ( ) ; }
Renders a given file with the supplied variables.

@access public
@param string $file    The file to be rendered.
@param mixed $vars     The variables to be substituted in the view.
@return string
@throws \LogicException
Renders a given file with the supplied variables .