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
From the official Twig documentation: "Macros are comparable with functions in regular programming languages. They are useful to put often used HTML idioms into reusable elements to not repeat yourself."
As of Twig 2.7, use the spaceless filter instead. This tag is not meant to "optimize" the size of the generated HTML content but merely to avoid extra whitespace between HTML tags to avoid browser rendering quirks under some circumstances.
To start writing Twig code in your HTML, there are only two different syntaxes: {{ }} The "say something" syntax. {% %} The "do something" syntax.
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!
If you look for deprecated features in Twig 2.*, you'll find there are none. 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.
But actually, in Twig v1, _self
was an object, with which you could do _self.templateName
, or call Twig macros with it. 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
).
So, if you used it in Twig v1 as an object - your code will fail in Twig v2.
Anyway, it seems like a bit messy resolution of the _self
issue.
I found it here:
http://twig.sensiolabs.org/doc/templates.html
Under Global Variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With