How to pass an array to a template? I am trying to get my first module to work which is supposed to render an array in his own template file.

1) I got an array of variables and return it in my controller

        array(
        '#theme' =&gt; 'myTheme',
        '#test_var' =&gt; $this-&gt;t('Test Value'),
        '#array' =&gt; array('key'=&gt;$myArray),
        );


2) in my .module I declare the hook_theme()

  return array(
'myTheme' =&gt; array(
  'variables' =&gt; array(
    'test_var' =&gt; '',
    'array' =&gt; array(),
    ),
),


);

3) Then I would like to print the variables
I am sure I missing something, and if I'm missing basic knowledge please let me know. I'm sure something is  wrong in the hook_theme since I don't know how to iterate my array in the template file.

&lt;p&gt;test_var: {{ test_var }}&lt;/p&gt;
&lt;p&gt;{{ array }}&lt;/p&gt;


If somebody could point me in the right direction, that would be nice :)

edit: the "Test Value" is rendering just fine
The variable names in the render array and theme hook need to match:

array(
  '#theme' =&gt; 'myTheme',
  '#test_var' =&gt; $this-&gt;t('Test Value'),
  '#doubles' =&gt; array('key'=&gt;$myArray),
);


Iterating an array in Twig is pretty straightforward:

{% for key,value in doubles %}
  Key : {{ key }}
  Value : {{ value }}
{% endfor %}