문제

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?

도움이 되었습니까?

해결책

Here's how you define an associative array in twig:

{{ html_anchor('categories/create', 'Add', { 'class': 'btn' }) }}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top