added support for {{ _self }} to provide an upgrade path from 1.x to 2.0

This commit is contained in:
Fabien Potencier
2016-12-08 08:50:52 +01:00
parent 8ad862b98e
commit 8ab764b4d3
4 changed files with 19 additions and 1 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.29.0 (2016-XX-XX)
* added support for {{ _self }} to provide an upgrade path from 1.x to 2.0 (replaces {{ _self.templateName }})
* deprecated silent display of undefined blocks
* deprecated support for mbstring.func_overload != 0
+2 -1
View File
@@ -181,7 +181,8 @@ Globals
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.
``Twig_Template`` instance. If you are using ``{{ _self.templateName }}``,
just replace it with ``{{ _self }}``.
Miscellaneous
-------------
+8
View File
@@ -39,6 +39,14 @@ abstract class Twig_Template implements Twig_TemplateInterface
$this->env = $env;
}
/**
* @internal this method will be removed in 2.0 and is only used internally to provide an upgrade path from 1.x to 2.0
*/
public function __toString()
{
return $this->getTemplateName();
}
/**
* Returns the template name.
*
@@ -0,0 +1,8 @@
--TEST--
_self returns the template name
--TEMPLATE--
{{ _self }}
--DATA--
return array()
--EXPECT--
index.twig