public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = [])
    {
        if (is_array($destination)) {
            $parameters = $destination;
            $destination = null;
        } elseif (is_array($extension)) {
            $parameters = $extension;
            $extension = '.html';
        }
        if (!$destination) {
            $destination = $path;
        }
        $path = realpath($path);
        $destination = realpath($destination);

        $success = 0;
        $errors = 0;
        if ($path && $destination) {
            $path = rtrim($path, '/\\');
            $destination = rtrim($destination, '/\\');
            $length = mb_strlen($path);
            foreach ($this->scanDirectory($path) as $file) {
                $relativeDirectory = trim(mb_substr(dirname($file), $length), '//\\');
                $filename = pathinfo($file, PATHINFO_FILENAME);
                $outputDirectory = $destination.DIRECTORY_SEPARATOR.$relativeDirectory;
                $counter = $this->renderAndWriteFile(
                    $file,
                    $outputDirectory.DIRECTORY_SEPARATOR.$filename.$extension,
                    $parameters
                ) ? 'success' : 'errors';
                $$counter++;
            }
        }

        return [$success, $errors];
    }
public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = [])
    {
        if (is_array($destination)) {
            $parameters = $destination;
            $destination = null;
        } elseif (is_array($extension)) {
            $parameters = $extension;
            $extension = '.html';
        }
        if (!$destination) {
            $destination = $path;
        }
        $path = realpath($path);
        $destination = realpath($destination);

        $success = 0;
        $errors = 0;
        if ($path && $destination) {
            $path = rtrim($path, '/\\');
            $destination = rtrim($destination, '/\\');
            $length = mb_strlen($path);
            foreach ($this->scanDirectory($path) as $file) {
                $relativeDirectory = trim(mb_substr(dirname($file), $length), '//\\');
                $filename = pathinfo($file, PATHINFO_FILENAME);
                $outputDirectory = $destination.DIRECTORY_SEPARATOR.$relativeDirectory;
                $counter = $this->renderAndWriteFile(
                    $file,
                    $outputDirectory.DIRECTORY_SEPARATOR.$filename.$extension,
                    $parameters
                ) ? 'success' : 'errors';
                $$counter++;
            }
        }

        return [$success, $errors];
    }
public function renderDirectory ( $ path , $ destination = null , $ extension = '.html' , array $ parameters = [ ] ) { if ( is_array ( $ destination ) ) { $ parameters = $ destination ; $ destination = null ; } elseif ( is_array ( $ extension ) ) { $ parameters = $ extension ; $ extension = '.html' ; } if ( ! $ destination ) { $ destination = $ path ; } $ path = realpath ( $ path ) ; $ destination = realpath ( $ destination ) ; $ success = 0 ; $ errors = 0 ; if ( $ path && $ destination ) { $ path = rtrim ( $ path , '/\\' ) ; $ destination = rtrim ( $ destination , '/\\' ) ; $ length = mb_strlen ( $ path ) ; foreach ( $ this -> scanDirectory ( $ path ) as $ file ) { $ relativeDirectory = trim ( mb_substr ( dirname ( $ file ) , $ length ) , '//\\' ) ; $ filename = pathinfo ( $ file , PATHINFO_FILENAME ) ; $ outputDirectory = $ destination . DIRECTORY_SEPARATOR . $ relativeDirectory ; $ counter = $ this -> renderAndWriteFile ( $ file , $ outputDirectory . DIRECTORY_SEPARATOR . $ filename . $ extension , $ parameters ) ? 'success' : 'errors' ; $ $ counter ++ ; } } return [ $ success , $ errors ] ; }
Render all pug template files in an input directory and output in an other or the same directory.
Return an array with success count and error count.

@param string       $path        pug input directory containing pug files
@param string       $destination pug output directory (optional)
@param string       $extension   file extension (optional, .html by default)
@param string|array $parameters  parameters (values for variables used in the template) (optional)

@return array
Render all pug template files in an input directory and output in an other or the same directory . Return an array with success count and error count .