* 1.12.1 (2013-XX-XX)
+ * relaxed globals management to avoid a BC break
* added support for {{ some_string[:2] }}
* 1.12.0 (2013-01-08)
* ``Twig_ParserInterface`` (use ``Twig_Parser`` instead)
* ``Twig_ExistsLoaderInterface`` (merged with ``Twig_LoaderInterface``)
* ``Twig_TemplateInterface`` (use ``Twig_Template`` instead)
+
+Globals
+-------
+
+* As of Twig 2.x, the ability to register a global variable after the runtime
+ or the extensions have been initialized is not possible anymore (but
+ changing the value of an already registered global is possible).
if (null === $this->globals) {
$this->initGlobals();
}
-
+
+ /* This condition must be uncommented in Twig 2.0
if (!array_key_exists($name, $this->globals)) {
throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
}
+ */
}
if ($this->extensionInitialized || $this->runtimeInitialized) {
$globals = $twig->getGlobals();
$this->assertEquals('bar', $globals['foo']);
+ /* to be uncomment in Twig 2.0
// globals cannot be added after runtime init
$twig = new Twig_Environment(new Twig_Loader_String());
$twig->addGlobal('foo', 'foo');
} catch (LogicException $e) {
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
}
+ */
}
public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()