Merge pull request #184 from fenom-template/master

sync develop
This commit is contained in:
Ivan Shalganov
2015-08-13 00:13:28 +03:00
5 changed files with 36 additions and 17 deletions

View File

@@ -117,6 +117,11 @@ class Fenom
*/
protected $_compile_dir = "/tmp";
/**
* @var string compile prefix ID template
*/
protected $_compile_id;
/**
* @var string[] compile directory for custom provider
*/
@@ -430,6 +435,18 @@ class Fenom
return $this;
}
/**
* Set compile prefix ID template
*
* @param string $id prefix ID to store compiled templates
* @return Fenom
*/
public function setCompileId($id)
{
$this->_compile_id = $id;
return $this;
}
/**
*
* @param callable $cb
@@ -1022,10 +1039,10 @@ class Fenom
foreach ($tpl as &$t) {
$t = str_replace(":", "_", basename($t));
}
return implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash));
return $this->_compile_id . implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash));
} else {
$hash = $tpl . ":" . $options;
return sprintf("%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash));
return sprintf($this->_compile_id . "%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash));
}
}

View File

@@ -988,10 +988,10 @@ class Template extends Render
$parser = $this->getStorage()->getAccessor($accessor);
$is_var = false;
if($parser) {
if(is_string($parser)) {
return call_user_func_array($parser, array($tokens->next(), $this, &$is_var));
} else {
if(is_array($parser)) {
return call_user_func_array($parser['parser'], array($parser['accessor'], $tokens->next(), $this, &$is_var));
} else {
return call_user_func_array($parser, array($tokens->next(), $this, &$is_var));
}
} else {
throw new \RuntimeException("Unknown accessor '$accessor'");