Loop array items via properties in Volt

Documentation says (http://docs.phalconphp.com/en/latest/reference/volt.html#variables)

Variables may have attributes which can be accessed using the syntax: foo.bar. If you are passing arrays, you CAN access using the square bracket syntax: foo[‘bar’]

{{ post.title }}
{{ post['title'] }}

Does CAN mean MUST for Volt? Or should I set up something to make it working? (Twig handle everything in dot notation and I miss it here)

PHP - data
$menu = array(array('id' => 'test1'), array('id' => 'test2'));
$this->view->setVar('menu', $menu);
{% for index, item in menu %}
    {{ index }} {{  item['id'] }} vs {{ item.id }}
{%  endfor %}

{{ item.id }} ends up with Notice: Trying to get property of non-object

edited Oct '14

You are correct.


{{ item['id'] }} // translates to item['id']


{{ item.id }} // translates to $item->id

We just need to correct the documentation in that area. If you don't mind can you either open an issue or send a pull request for this in the docs repo?


It would be great if arrays and objects can be accessed the same way with dot:

{{ post.title }}