Cleanup cache initialization from options

This commit is contained in:
Amit Snyderman
2013-09-05 18:16:00 -04:00
parent 3e876fd984
commit 71eaed2778
+11 -11
View File
@@ -55,7 +55,8 @@ class Mustache_Engine
* // A Mustache cache instance. Uses a NoopCache if not specified. * // A Mustache cache instance. Uses a NoopCache if not specified.
* 'cacher' => new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/tmp/cache/mustache'), * 'cacher' => new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/tmp/cache/mustache'),
* *
* // A cache directory for compiled templates. Mustache will not cache templates unless this is set * // A Mustache cache instance or a cache directory string for compiled templates.
* // Mustache will not cache templates unless this is set
* 'cache' => dirname(__FILE__).'/tmp/cache/mustache', * 'cache' => dirname(__FILE__).'/tmp/cache/mustache',
* *
* // Override default permissions for cache files. Defaults to using the system-defined umask. It is * // Override default permissions for cache files. Defaults to using the system-defined umask. It is
@@ -113,16 +114,15 @@ class Mustache_Engine
$this->templateClassPrefix = $options['template_class_prefix']; $this->templateClassPrefix = $options['template_class_prefix'];
} }
if (isset($options['cacher'])) { if (isset($options['cache'])) {
$this->cache = $options['cacher']; $cache = $options['cache'];
} else if (isset($options['cache'])) {
$cacheFileMode = isset($options['cache_file_mode']) if (is_string($cache)) {
? $options['cache_file_mode'] $mode = isset($options['cache_file_mode']) ? $options['cache_file_mode'] : null;
: null; $cache = new Mustache_Cache_FilesystemCache($cache, $mode);
$this->cache = new Mustache_Cache_FilesystemCache( }
$options['cache'],
$cacheFileMode $this->setCache($cache);
);
} }
if (isset($options['loader'])) { if (isset($options['loader'])) {