I have a function that generates an array containing menu items:
Item 1
SubItem 1a
SubItem 1b
Item2
SubItem 2a
...
I have a twig extension that can return this as an array. I need to be able to set this array to a variable in twig, so that I can use it through out my template.
I have tried doing {% set myArray = {{ myFunction('menuname') }} %}
I also tried:
{% set myArray %}
{{ myFunction('menuname') }}
{% endset %}
However, that did not work either. Is there a way to do this?
Got it!
Use
{% set myArray = myFunction('menuname') %}