src/Installer.php
private function compileTemplate($templatePath, $destinationPath, $data = null)
    {
        if ($data == null) {
            $data = $destinationPath;
            $destinationPath = null;
        }
        
        if (! isset($this->templates[$templatePath])) {
            $this->templates[$templatePath] = file_get_contents($templatePath);
        }
        
        $compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
            if (isset($data[$matches[1]])) {
                return $data[$matches[1]];
            }
            
            return $matches[0];
        }, $this->templates[$templatePath]);
        
        if ($destinationPath) {
            file_put_contents($destinationPath, $compiled);
        }
        
        return $compiled;
    }
private function compileTemplate($templatePath, $destinationPath, $data = null)
    {
        if ($data == null) {
            $data = $destinationPath;
            $destinationPath = null;
        }
        
        if (! isset($this->templates[$templatePath])) {
            $this->templates[$templatePath] = file_get_contents($templatePath);
        }
        
        $compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
            if (isset($data[$matches[1]])) {
                return $data[$matches[1]];
            }
            
            return $matches[0];
        }, $this->templates[$templatePath]);
        
        if ($destinationPath) {
            file_put_contents($destinationPath, $compiled);
        }
        
        return $compiled;
    }
private function compileTemplate ( $ templatePath , $ destinationPath , $ data = null ) { if ( $ data == null ) { $ data = $ destinationPath ; $ destinationPath = null ; } if ( ! isset ( $ this -> templates [ $ templatePath ] ) ) { $ this -> templates [ $ templatePath ] = file_get_contents ( $ templatePath ) ; } $ compiled = preg_replace_callback ( '/{{\s*([A-z0-9_-]+)\s*}}/' , function ( $ matches ) use ( $ data ) { if ( isset ( $ data [ $ matches [ 1 ] ] ) ) { return $ data [ $ matches [ 1 ] ] ; } return $ matches [ 0 ] ; } , $ this -> templates [ $ templatePath ] ) ; if ( $ destinationPath ) { file_put_contents ( $ destinationPath , $ compiled ) ; } return $ compiled ; }
Compile a template file.

@param  string  $templatePath
@param  string  $destinationPath
@param  array|null  $data
@return string
Compile a template file .