Update generated class name for delimiters option.
Add some docs there, make it slightly easier to update the generated class name.
This commit is contained in:
+22
-10
@@ -594,22 +594,34 @@ class Mustache_Engine
|
|||||||
/**
|
/**
|
||||||
* Helper method to generate a Mustache template class.
|
* Helper method to generate a Mustache template class.
|
||||||
*
|
*
|
||||||
|
* This method must be updated any time options are added which make it so
|
||||||
|
* the same template could be parsed and compiled multiple different ways.
|
||||||
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
*
|
*
|
||||||
* @return string Mustache Template class name
|
* @return string Mustache Template class name
|
||||||
*/
|
*/
|
||||||
public function getTemplateClassName($source)
|
public function getTemplateClassName($source)
|
||||||
{
|
{
|
||||||
return $this->templateClassPrefix . md5(sprintf(
|
// For the most part, adding a new option here should do the trick.
|
||||||
'version:%s,escape:%s,entity_flags:%i,charset:%s,strict_callables:%s,pragmas:%s,source:%s',
|
//
|
||||||
self::VERSION,
|
// Pick a value here which is unique for each possible way the template
|
||||||
isset($this->escape) ? 'custom' : 'default',
|
// could be compiled... but not necessarily unique per option value. See
|
||||||
$this->entityFlags,
|
// escape below, which only needs to differentiate between 'custom' and
|
||||||
$this->charset,
|
// 'default' escapes.
|
||||||
$this->strictCallables ? 'true' : 'false',
|
//
|
||||||
implode(' ', $this->getPragmas()),
|
// Keep this list in alphabetical order :)
|
||||||
$source
|
$options = array(
|
||||||
));
|
'charset' => $this->charset,
|
||||||
|
'delimiters' => $this->delimiters,
|
||||||
|
'entityFlags' => $this->entityFlags,
|
||||||
|
'escape' => isset($this->escape) ? 'custom' : 'default',
|
||||||
|
'pragmas' => $this->getPragmas(),
|
||||||
|
'strictCallables' => $this->strictCallables,
|
||||||
|
'version' => self::VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->templateClassPrefix . md5(json_encode($options) . "\n" . $source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user