title: Symfony2, twig and JavaScript
body: <p>What do I need to do to get twig to process a JavaScript file?  I have an html.twig that uses a JavaScript twig.  Something like this:</p>
  
  <pre><code>{% extends 'BaseBundle::layout.html.twig' %}
  
  {% block javascripts %}
      {{ parent() }}
      {% javascripts
          '@BaseBundle/Resources/js/main.js.twig'
      %}
      {% endjavascripts %}
  {% endblock %}
  
  &lt; more template omitted &gt;
  </code></pre>
  
  <p>And parts of main.js.twig:</p>
  
  <pre><code>function testFunction()
  {
      alert('{{VariableFromPHP}}');
  }
  </code></pre>
  
  <p>And the controller:</p>
  
  <pre><code>/**
   * @Route("/",name="home")
   * @Template("MyBundle:Default:index.html.twig")
   */
  public function indexAction()
  {
     return array( 'VariableFromPHP' =&gt; 'Hello World');
  }
  </code></pre>
  
  <p>I expected the JavaScript to look like this at run-time: </p>
  
  <pre><code>alert('Hello World');
  </code></pre>
  
  <p>But, the code is unchanged.  Any ideas what I am doing wrong?</p>
  
  <p>Thanks,
  Scott</p>