Anonymous function in template
I used the filter function on an object collection, but when I pass it an anonymous function in parameter I get an error during the rendering process of the page.
{{ items.filter((item) => return item.value > 5) }}
I am obliged to declare the anonymous function in the controller, then pass it in the parameters of the view.
async ({view}) => {
return view.render('template', {
filterFn: (item) => {
return item.lengh > 0
}
})
}
And then :
{{ items.filter(filterFn) }}
Ues templates are not Javascript files, and hence an anonymous function is not allowed.
Okey so I can't pass general javascript expression to edge template. Thanks
You can always use view presenters to achieve this kind of thing.
Okey. Thanks
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.