Hi.
I have a problem with using my functions in Volt. Ok, i have a simple function:
$volt->getCompiler()->addFunction('icon', function($resolved_args, $expr_args) {
return '\Helpers\VoltFunctionsHelper::icon(' . $resolved_args . ');';
});
public static function icon($key, $classes = '') {
return '<i class="fa fa-' . trim($key) . ($classes !== '' ? ' ' . trim($classes) : '') . '"></i>';
}
I would like to use the result of my function as an argument for the macro "link_to", like I do bellow:
{{ link_to('somelink', image('imagelink')) }}
{{ link_to('somelink', icon('someicon')) }}
My function "icon" works correctly when loosely in the template code, but when I try to use it in macro "link_to" as link text, I get an parse error:
Parse error: syntax error, unexpected ';', expecting ']'
Why am I getting this error? How could I define a macro function instead (not in template source)?