Backward incompatibilities:
* The short notation of the `block` tag changed.
+ * changed the cache option to only accepts an explicit path to a cache directory or false
* added a way to add token parsers, filters, and visitors without creating an extension
* added three interfaces: Twig_NodeInterface, Twig_TokenParserInterface, and Twig_FilterInterface
* changed the generated code to match the new coding standards
* `base_template_class`: The base template class to use for generated
templates (default to `Twig_Template`).
- * `cache`: It can take three values:
-
- * `null` (the default): Twig will create a sub-directory under the system
- temp directory to store the compiled templates (not recommended as
- templates from two projects with the same name will share the same cache if
- your projects share the same Twig source code).
-
- * `false`: disable the compile cache altogether (not recommended).
-
- * An absolute path where to store the compiled templates.
+ * `cache`: An absolute path where to store the compiled templates, or false
+ to disable caching (which is the default).
* `auto_reload`: When developing with Twig, it's useful to recompile the
template whenever the source code changes. If you don't provide a value for
* templates (default to Twig_Template).
*
* * cache: Can be one of three values:
- * * null (the default): Twig will create a sub-directory under the system tmp directory
- * (not recommended as templates from two projects with the same name will share the cache)
- * * false: disable the compile cache altogether
+ * * false: disable the compilation cache (default)
* * An absolute path where to store the compiled templates
*
* * auto_reload: Whether to reload the template is the original source changed.
$this->autoReload = isset($options['auto_reload']) ? (bool) $options['auto_reload'] : $this->debug;
$this->extensions = array('core' => new Twig_Extension_Core());
$this->runtimeInitialized = false;
- $this->setCache(isset($options['cache']) ? $options['cache'] : null);
+ if (isset($options['cache']) && $options['cache'])
+ {
+ $this->setCache($options['cache']);
+ }
}
public function getBaseTemplateClass()
public function setCache($cache)
{
- $this->cache = null === $cache ? sys_get_temp_dir().DIRECTORY_SEPARATOR.'twig_'.md5(dirname(__FILE__)) : $cache;
+ $this->cache = $cache;
- if (false !== $this->cache && !is_dir($this->cache)) {
+ if ($this->cache && !is_dir($this->cache)) {
mkdir($this->cache, 0755, true);
}
}