public function generate(Page $page) { $site = $this->blazon->getSite(); $config = $page->getConfig(); $outputPath = $page->getBaseDir() . DIRECTORY_SEPARATOR; $pageName = $page->getName(); $pageOutputName = $pageName . '.html'; $commandTemplate = $this->blazon->getTwig()->loadTemplate('@Templates/command.html.twig'); $pageTemplate = $this->blazon->getTwig()->loadTemplate('@Templates/commands.html.twig'); $commands = []; foreach ($config['classes'] as $className) { $command = $this->loadCommand($className, $pageName); $outputName = $this->cmdNameToResourceName($command, $page); $commands[$outputName] = $command; } foreach ($commands as $outputName => $command) { $data = ['site' => $site, 'page' => $page, 'command' => $command, 'index_page' => $page, 'index_page_url' => $pageOutputName]; $output = $commandTemplate->render($data); file_put_contents($outputPath . $outputName, $output); } $data = ['site' => $site, 'page' => $page, 'commands' => $commands]; $output = $pageTemplate->render($data); file_put_contents($outputPath . $pageOutputName, $output); return; }
public function generate(Page $page) { $template = $this->blazon->getTwig()->loadTemplate($page->getSrc()); $site = $this->blazon->getSite(); $data = ['site' => $site, 'page' => $page]; $output = $template->render($data); file_put_contents($page->getBaseDir() . '/' . $page->getName() . '.html', $output); }
public function generate(Page $page) { $parsedown = new Parsedown(); $html = $parsedown->text($this->content); $layout = $page->getLayout(); if (!$layout) { $layout = 'default'; } $template = $this->blazon->getTwig()->loadTemplate('templates/' . $layout . '.html.twig'); $site = $this->blazon->getSite(); $data = ['content' => $html, 'site' => $site, 'page' => $page]; $output = $template->render($data); file_put_contents($page->getBaseDir() . '/' . $page->getName() . '.html', $output); }