Closed vhbmsp closed 11 years ago
Tag is the name of a service in Phalcon\Tag, this is why Volt tries to use the service 'tag' instead of the variable. This also happens with: 'url', 'router', 'dispatcher', 'session', 'request', 'response', etc.
So they are like reserved words and can't be used in var names inside the view, correct? It this case, I think that this has do be more clear in the Volt documentation. What I understand from the docs, is that we have Phalcon\Tag functions that you can call from volt templates like link_to(), text_field(), etc, but nothing saying about the name of variables. With the increase number of services that Phalcon has, this kind of names collision will occur more often and must be clear for developers what they can't use when setting variables into views.
It's mentioned in this section: http://docs.phalconphp.com/en/latest/reference/volt.html#inject-services-into-a-template
If we set a variable with the name 'tag' and try to output it in the view like {{ tag.title }} it will raise an Notice error:
The 'tag' variable name is colliding with Phalcon\Tag
Sample Code for testing follows:
== CONTROLLER ==
== Volt VIEW ==