[英]Twig “_self” variable
Where is documented the existence of this keyword? 在哪里记录了这个关键字的存在? (I guess it is a constant, rather than an object, right?).
(我想这是一个常数,而不是一个对象,对吧?)。
Anyway, I'd like to know where it is documented, to see if there are other keywords that I don't know about. 无论如何,我想知道它在哪里记录,看看是否还有其他我不了解的关键词。
Thanks 谢谢
This doesn't really answer the question, but I think it's important to mention it. 这并没有真正回答这个问题,但我认为提及它很重要。 The
_self
itself is not really deprecated nor removed, but its usage is! _self
本身并没有真正被弃用或删除,但它的用法是!
If you look for deprecated features in Twig 2.*, you'll find there are none . 如果您在Twig 2. *中查找已弃用的功能,您会发现没有 。 So, you may think falsely that you're safe, or scratch your head (like I did) in finding why did it stop working in v2.0.
所以,你可能会错误地认为你是安全的,或者在你发现为什么它在v2.0中停止工作时刮挠你的头(就像我一样)。
But actually, in Twig v1, _self
was an object, with which you could do _self.templateName
, or call Twig macros with it. 但实际上,在Twig v1中,
_self
是一个对象,您可以使用它来执行_self.templateName
,或者使用它来调用Twig宏。 Its usage as object was deprecated but it worked. 它作为对象的用法已被弃用但它有效。
In Twig v2, _self
is no more an object but a string, which actually holds the templates name (the previous value of _self.templateName
). 在Twig v2中,
_self
不再是一个对象而是一个字符串,它实际上包含模板名称( _self.templateName
的前一个值)。
So, if you used it in Twig v1 as an object - your code will fail in Twig v2. 因此,如果您在Twig v1中使用它作为对象 - 您的代码将在Twig v2中失败。 Anyway, it seems like a bit messy resolution of the
_self
issue. 无论如何,对于
_self
问题似乎有点混乱。
I found it here: 我在这里找到了:
http://twig.sensiolabs.org/doc/templates.html http://twig.sensiolabs.org/doc/templates.html
Under Global Variables 在全局变量下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.