I have a symfony controller returning this:
return $this->render('MyBundle:Default:index.html.twig', array('menu' => $menu));
menu
is a Menu
object.
In my template I want to call a method from the Menu class:
getHTML(string s1, String s2, array tab)
returning a HTML string.
How do I do that in the template? Is it even possible ?
Yea, it's possible:
{{ menu.getHTML('first-string', 'second-string', ['tab1', 'tab2']) }}
Since Twig handles getters and issers automatically, you can omit the get
part:
{{ menu.HTML(...) }}