Пример #1
0
 public function drawFile(AbstractFile $file)
 {
     $outputFile = ltrim($file->getOutputFile(), "/");
     $output = pathinfo($this->outputDir . "/" . $outputFile);
     $outputDirname = $output["dirname"];
     $outputBasename = $output["basename"];
     $outputFilename = $outputDirname . "/" . $outputBasename;
     // todo : check if writable
     if (!file_exists($outputDirname)) {
         mkdir($outputDirname, 0777, true);
     }
     $subDirNumber = count(explode("/", $outputFile)) - 1;
     if ($subDirNumber > 0) {
         $pathToRoot = str_repeat("../", $subDirNumber);
     } else {
         $pathToRoot = "./";
     }
     $template = new Template($file->getData(), $this->themeDir, $file->getTemplateName());
     $template->setPathToRoot($pathToRoot);
     $template->setThemeOptions($this->options);
     $template->setProjectConfig($this->projectConfig);
     touch($outputFilename);
     $template->write($outputFilename);
 }
Пример #2
0
 public function partial($fileName, array $data = array())
 {
     $newLevel = $this->nestedLevel + 1;
     $template = new Template($this->theme, array_merge($this->data, $data), $fileName, $newLevel);
     $template->setPathToRoot($this->getPathToRoot());
     $template->setThemeOptions($this->themeOptions);
     $template->setProjectConfig($this->projectConfig);
     return $template->parse();
 }