mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
removed deprecated _self variable
This commit is contained in:
@@ -59,13 +59,6 @@ special ``_self`` variable to import them:
|
||||
|
||||
<p>{{ forms.input('username') }}</p>
|
||||
|
||||
.. warning::
|
||||
|
||||
When you define a macro in the template where you are going to use it, you
|
||||
might be tempted to call the macro directly via ``_self.input()`` instead
|
||||
of importing it; even if seems to work, this is just a side-effect of the
|
||||
current implementation and it won't work anymore in Twig 2.x.
|
||||
|
||||
When you want to use a macro in another macro from the same file, you need to
|
||||
import it locally:
|
||||
|
||||
|
||||
@@ -124,7 +124,6 @@ Global Variables
|
||||
|
||||
The following variables are always available in templates:
|
||||
|
||||
* ``_self``: references the current template (deprecated since Twig 1.20);
|
||||
* ``_context``: references the current context;
|
||||
* ``_charset``: references the current charset.
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
class Twig_Node_Expression_Name extends Twig_Node_Expression
|
||||
{
|
||||
private $specialVars = array(
|
||||
'_self' => '$this',
|
||||
'_context' => '$context',
|
||||
'_charset' => '$this->env->getCharset()',
|
||||
);
|
||||
|
||||
@@ -114,8 +114,7 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
||||
}
|
||||
} elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) {
|
||||
$name = $node->getNode('node')->getAttribute('name');
|
||||
// attributes on template instances are safe
|
||||
if ('_self' == $name || in_array($name, $this->safeVars)) {
|
||||
if (in_array($name, $this->safeVars)) {
|
||||
$this->setSafe($node, array('all'));
|
||||
} else {
|
||||
$this->setSafe($node, array());
|
||||
|
||||
@@ -21,7 +21,6 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
|
||||
public function getTests()
|
||||
{
|
||||
$node = new Twig_Node_Expression_Name('foo', 1);
|
||||
$self = new Twig_Node_Expression_Name('_self', 1);
|
||||
$context = new Twig_Node_Expression_Name('_context', 1);
|
||||
|
||||
$env = new Twig_Environment(new Twig_Loader_Array(array()), array('strict_variables' => true));
|
||||
@@ -30,7 +29,6 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
|
||||
return array(
|
||||
array($node, "// line 1\n".'(isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : $this->notFound("foo", 1))', $env),
|
||||
array($node, $this->getVariableGetter('foo', 1), $env1),
|
||||
array($self, "// line 1\n\$this"),
|
||||
array($context, "// line 1\n\$context"),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user