我想实现一个小型PHP模板引擎,比如smarty,它允许我编写自己的php标记(if,for .)
现在,我的问题是如何在修改模板文件时自动编译?
例如: Servlet。当我们修改servlet并等待几秒钟时,eclipse会告诉您修改后的servlet类被重新编译了!
任何帮助都会很好!
发布于 2014-01-13 04:15:15
您可以在缓存的编译模板和源文件之间检查修改的日期。
$cacheFileAge = @filemtime($this->cacheFile); //Get Time
foreach(array_merge(array($template),$this->snipFiles) as $f)
if($cacheFileAge < filemtime($f)) //Compare every template to cache file
return $this->parse(file_get_contents($template)); //If cache file older than one, re-compile it
debugLog("Using Cached file ({$this->cacheFile})");
include($this->cacheFile); //use cached file此示例取自另一个php模板项目哈梅莱。
https://stackoverflow.com/questions/21083700
复制相似问题