コード例 #1
0
ファイル: CacheHelper.php プロジェクト: XaBerr/JUICE
 /**
  * Scan a directory recursively, compile them and save them into the cache directory.
  *
  * @param string $directory the directory to search in pug templates
  *
  * @return array count of cached files and error count
  */
 public function cacheDirectory($directory)
 {
     $success = 0;
     $errors = 0;
     $extensions = new ExtensionsHelper($this->pug->getOption('extension'));
     foreach (scandir($directory) as $object) {
         if ($object === '.' || $object === '..') {
             continue;
         }
         $input = $directory . DIRECTORY_SEPARATOR . $object;
         if (is_dir($input)) {
             list($subSuccess, $subErrors) = $this->cacheDirectory($input);
             $success += $subSuccess;
             $errors += $subErrors;
             continue;
         }
         if ($extensions->hasValidTemplateExtension($object)) {
             $this->isCacheUpToDate($input, $path);
             try {
                 file_put_contents($path, $this->pug->compile($input));
                 $success++;
             } catch (\Exception $e) {
                 $errors++;
             }
         }
     }
     return array($success, $errors);
 }
コード例 #2
0
ファイル: Extensions.php プロジェクト: XaBerr/JUICE
 /**
  * Get list of supported extensions.
  *
  * @return array
  */
 public function getExtensions()
 {
     $extensions = new ExtensionsHelper($this->getOption('extension'));
     return $extensions->getExtensions();
 }