Here's how you define an associative array in twig:
{{ html_anchor('categories/create', 'Add', { 'class': 'btn' }) }}
Pregunta
I am converting the PHP based template to TWIG based template in FuelPHP.
echo Html::anchor('categories/create', 'Add', array('class' => 'btn'));
I found out with some help that the equivalent tag for TWIG is html_anchor which works fine. But as in this case, there is an third parameter passed as an array. How that can be converted for TWIG?
I tried the below found 2 lines and both failed with error so I assume its not the correct way.
{{ html_anchor('categories/create', 'Add', array('class' => 'btn')) }}
Twig arrays has [] format, so I tried this too.
{{ html_anchor('categories/create', 'Add', ['class' : 'btn']) }}
What's the correct way of handling this?
Solución
Here's how you define an associative array in twig:
{{ html_anchor('categories/create', 'Add', { 'class': 'btn' }) }}