static function input($content, $assignVar) { self::$assignVar = $assignVar; //处理包含 $content = self::include_replace($content); //去除注释 $arr1[] = '/<\\{\\s*\\/\\*.*\\*\\/\\s*\\}>/'; $arr2[] = ''; $content = preg_replace($arr1, $arr2, $content); //处理循环 $content = self::variable_replace(self::foreach_replace($content)); $content = self::tags_replace($content); //处理函数 return self::function_replace($content); }
function cache() { $content = compile::input(file_get_contents($this->templateFile), array_keys($this->var)); file_put_contents($this->cacheFile, $content); }
/** * 解析模版 +创建编译文件 * @param type $tplFile * @param type $compileFile */ public function compile() { if (!$this->checkCompile()) { return; } load_file(PATH_HD . '/libs/usr/view/hd/compile.class.php'); $assignVar = array_keys(self::$vars); //assign分配的变量 $compileObj = new compile($this->tplFile, $this->compileFile, $assignVar); $compileObj->run(); }
$options[] = 'quiet'; break; case '--pretend': case '-p': $options[] = 'pretend'; break; case '--recursive': case '-r': $options[] = 'recursive'; break; default: $exploded = explode('=', $arg); if (count($exploded) == 2) { switch ($exploded[0]) { case '--compilation_level': case '-l': $option['compilation_level'] = $exploded[1]; break; default: help(); } } else { if ($is_option || $path) { help(); } $path = $arg; } } } compile::it($path, $options);