title: Setting the result of a function to a variable in twig
body: <p>I have a function that generates an array containing menu items:</p>
  
  <pre><code>Item 1
    SubItem 1a
    SubItem 1b
  
  Item2
    SubItem 2a
    ...
  </code></pre>
  
  <p>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.</p>
  
  <p>I have tried doing <code>{% set myArray = {{ myFunction('menuname') }} %}</code></p>
  
  <p>I also tried:</p>
  
  <pre><code>{% set myArray %}
    {{ myFunction('menuname') }}
  {% endset %}
  </code></pre>
  
  <p>However, that did not work either. Is there a way to do this?</p>