public function parse(array $vars = []): string
    {
        ++$this->parsed; // Parsing now.

        if ($this->ext === 'php') {
            $_this = $this; // `$this` in symbol table.
            // ↑ Strange magic makes it possible for `$this` to be used from
            // inside the template file also. We just need to reference it here.
            // See: <http://stackoverflow.com/a/4994799/1219741>

            unset($_this, $vars['this']); // Avoid conflicts.
            $this->vars = $vars; // Set current template variables.
            unset($vars); // Don't include as a part of template variables.

            extract($this->vars); // Extract for template.

            ob_start(); // Output buffer.
            require $this->dir.'/'.$this->file;
            return ob_get_clean();
        } else {
            return file_get_contents($this->dir.'/'.$this->file);
        }
    }
public function parse(array $vars = []): string
    {
        ++$this->parsed; // Parsing now.

        if ($this->ext === 'php') {
            $_this = $this; // `$this` in symbol table.
            // ↑ Strange magic makes it possible for `$this` to be used from
            // inside the template file also. We just need to reference it here.
            // See: <http://stackoverflow.com/a/4994799/1219741>

            unset($_this, $vars['this']); // Avoid conflicts.
            $this->vars = $vars; // Set current template variables.
            unset($vars); // Don't include as a part of template variables.

            extract($this->vars); // Extract for template.

            ob_start(); // Output buffer.
            require $this->dir.'/'.$this->file;
            return ob_get_clean();
        } else {
            return file_get_contents($this->dir.'/'.$this->file);
        }
    }
public function parse ( array $ vars = [ ] ) : string { ++ $ this -> parsed ; // Parsing now. if ( $ this -> ext === 'php' ) { $ _this = $ this ; // `$this` in symbol table. // ↑ Strange magic makes it possible for `$this` to be used from // inside the template file also. We just need to reference it here. // See: <http://stackoverflow.com/a/4994799/1219741> unset ( $ _this , $ vars [ 'this' ] ) ; // Avoid conflicts. $ this -> vars = $ vars ; // Set current template variables. unset ( $ vars ) ; // Don't include as a part of template variables. extract ( $ this -> vars ) ; // Extract for template. ob_start ( ) ; // Output buffer. require $ this -> dir . '/' . $ this -> file ; return ob_get_clean ( ) ; } else { return file_get_contents ( $ this -> dir . '/' . $ this -> file ) ; } }
Parse template.

@since 150424 Initial release.

@param array $vars Template vars.

@return string Parsed template contents.
Parse template .