title: Twig dynamic variables
body: <p>I am currently evaluating templating engines and really like the look of Twig.  For our project we have thousands of variables and to set them all on the render call will be very inefficient to say the least. Our variables are all arrays, similar to this:</p>
  
  <pre><code>{{table.column}}
  </code></pre>
  
  <p>Is it possible for Twig to request our code to assign variables when they are needed, if so how (dynamic arrays)?</p>
  
  <p>I <strong>don't</strong> want to have to use <code>{{attribute(table.column)}}</code>, I would prefer to use simply <code>{{table.column}}</code>.</p>
  
  <p>As a thought, would I be able to set the variables like so:</p>
  
  <pre><code>function set_var($var) {
    if ($var=="table")
       return array("column"=&gt;"Hello","there"=&gt;"there","world"=&gt;"world");
  }
  ....
  echo $twig-&gt;render(array('table' =&gt; set_var("table") ));
  // or
  $twig-&gt;addGlobal("table", set_var("table") );
  </code></pre>
  
  <p>Thanks in advance</p>