* fixed iterator_to_array() usage
* changed the date filter to support any date format supported by DateTime
- * added ignore_invalid_variables setting to throw an exception when an invalid variable is used in a template (disabled automatically when debug is true)
+ * added strict_variable setting to throw an exception when an invalid variable is used in a template (disabled by default when debug is false)
* added the lexer, parser, and compiler as arguments to the Twig_Environment constructor
* 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
the `auto_reload` option, it will be determined automatically based on the
`debug` value.
- * `ignore_invalid_variables` (new in Twig 0.9.7): If set to `true`, Twig will
+ * `strict_variables` (new in Twig 0.9.7): If set to `false`, Twig will
silently ignore invalid variables (variables and or attributes/methods that
- do not exist) and replace them with a `null` value. When set to `false`,
+ do not exist) and replace them with a `null` value. When set to `true`,
Twig throws an exception instead. If you don't provide a value for the
- `ignore_invalid_variables` option, it will be determined automatically
- based on the `debug` value (`false` when in debug mode, `true` otherwise).
+ `strict_variables` option, it will be determined automatically based on the
+ `debug` value.
>**CAUTION**
>Before Twig 0.9.3, the `cache` and `auto_reload` options did not exist. They
protected $filters;
protected $runtimeInitialized;
protected $loadedTemplates;
- protected $ignoreInvalidVars;
+ protected $strictVariables;
/**
* Constructor.
* If you don't provide the auto_reload option, it will be
* determined automatically base on the debug value.
*
- * * ignore_invalid_variables: Whether to ignore invalid variables in templates (default to the opposite value of debug).
+ * * strict_variables: Whether to ignore invalid variables in templates (default to the opposite value of debug).
*
* @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance
* @param array $options An array of options
$this->baseTemplateClass = isset($options['base_template_class']) ? $options['base_template_class'] : 'Twig_Template';
$this->autoReload = isset($options['auto_reload']) ? (bool) $options['auto_reload'] : $this->debug;
$this->extensions = array('core' => new Twig_Extension_Core());
- $this->ignoreInvalidVars = isset($options['ignore_invalid_variables']) ? (bool) $options['ignore_invalid_variables'] : !$this->debug;
+ $this->strictVariables = isset($options['strict_variables']) ? (bool) $options['strict_variables'] : $this->debug;
$this->runtimeInitialized = false;
if (isset($options['cache']) && $options['cache']) {
$this->setCache($options['cache']);
$this->autoReload = (Boolean) $autoReload;
}
- public function enableignoreInvalidVars()
+ public function enableStrictVariables()
{
- $this->ignoreInvalidVars = true;
+ $this->strictVariables = true;
}
- public function disableignoreInvalidVars()
+ public function disableStrictVariables()
{
- $this->ignoreInvalidVars = false;
+ $this->strictVariables = false;
}
- public function ignoresInvalidVars()
+ public function isStrictVariables()
{
- return $this->ignoreInvalidVars;
+ return $this->strictVariables;
}
public function getCache()
return $context[$item];
}
- if ($this->env->ignoresInvalidVars()) {
+ if (!$this->env->isStrictVariables()) {
return null;
}
}
if ($arrayOnly || !is_object($object)) {
- if ($this->env->ignoresInvalidVars()) {
+ if (!$this->env->isStrictVariables()) {
return null;
}
} elseif (isset($this->cache[$class]['__call'])) {
$method = $item;
} else {
- if ($this->env->ignoresInvalidVars()) {
+ if (!$this->env->isStrictVariables()) {
return null;
}