Phrozn\Site\View\Base::compile PHP Method

compile() public method

Create static version of a concrete page
public compile ( array $vars = [] ) : Phrozn\Site\View
$vars array List of variables passed to template engine
return Phrozn\Site\View
    public function compile($vars = array())
    {
        $out = $this->render($vars);
        $outputFile = $this->getOutputFile();
        $destinationDir = dirname($outputFile);
        if (!is_dir($destinationDir)) {
            mkdir($destinationDir, 0777, true);
        }
        if (!is_dir($outputFile)) {
            file_put_contents($outputFile, $out);
        } else {
            throw new \RuntimeException(sprintf('Output path "%s" is directory.', $outputFile));
        }
        return $out;
    }