문제

I have the below line of code in the FuelPHP view file (php) and I am converting the project code from PHP template to TWIG template engine.

<?php echo Html::anchor('quiz/edit/'.$quiz->id, 'Edit'); ?>

How can I convert the below line of code to work with TWIG template?

I tried the below thing in the .php file:

$data['edit_url']=  Html::anchor('quiz/edit/'.$quiz->id, 'Edit');

And in .twig file, I use the below line:

{{edit_url}

With this I get the HTML code as a text(without hyperlink) as the html is escaped to normal text by default.

What I was expecting is a URL hyperlink without being escaped.

Note: I tried the below code and I get NULL out of it.

$data['edit_url']= Router::get('quiz/edit/',array('id' => $quiz->id));
도움이 되었습니까?

해결책

The FuelPHP parser for Twig makes a lot of Fuel helpers available using a Twig extension.

Check the ./classes/twig/fuel/extension.php file in the Parser package to see which ones. Html::anchor is included too.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top