Skip to content
Permalink
Browse files

undeprecated _self

  • Loading branch information...
fabpot committed Jan 16, 2016
1 parent 934f6f0 commit b490e6594f5de57bc9899c53661a4667cd598aa2
Showing with 7 additions and 12 deletions.
  1. +1 −0 CHANGELOG
  2. +5 −3 doc/deprecated.rst
  3. +1 −1 doc/templates.rst
  4. +0 −8 lib/Twig/Node/Expression/Name.php
@@ -1,5 +1,6 @@
* 1.23.2 (2015-XX-XX)

* undeprecated _self (should only be used to get the template name, not the template instance)
* added versions in deprecated messages
* made file cache tolerant for trailing (back)slashes on directory configuration
* deprecated unused Twig_Node_Expression_ExtensionReference class
@@ -144,9 +144,11 @@ Globals
or the extensions have been initialized is not possible anymore (but
changing the value of an already registered global is possible).

* As of Twig 1.x, the ``_self`` global variable is deprecated except for usage
in the ``from`` and the ``import`` tags. In Twig 2.0, ``_self`` is not
exposed anymore but still usable in the ``from`` and the ``import`` tags.
* As of Twig 1.x, using the ``_self`` global variable to get access to the
current ``Twig_Template`` instance is deprecated; most usages only need the
current template name, which will continue to work in Twig 2.0. In Twig 2.0,
``_self`` returns the current template name instead of the current
``Twig_Template`` instance.

Miscellaneous
-------------
@@ -127,7 +127,7 @@ Global Variables

The following variables are always available in templates:

* ``_self``: references the current template (deprecated since Twig 1.20);
* ``_self``: references the current template;
* ``_context``: references the current context;
* ``_charset``: references the current charset.

@@ -30,19 +30,11 @@ public function compile(Twig_Compiler $compiler)
if ($this->getAttribute('is_defined_test')) {
if ($this->isSpecial()) {
if ('_self' === $name) {
@trigger_error(sprintf('Global variable "_self" is deprecated since version 1.21 in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED);
}
$compiler->repr(true);
} else {
$compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
}
} elseif ($this->isSpecial()) {
if ('_self' === $name) {
@trigger_error(sprintf('Global variable "_self" is deprecated since version 1.21 in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED);
}
$compiler->raw($this->specialVars[$name]);
} elseif ($this->getAttribute('always_defined')) {
$compiler

0 comments on commit b490e65

Please sign in to comment.
You can’t perform that action at this time.