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:
{% extends 'BaseBundle::layout.html.twig' %}
{% block javascripts %}
{{ parent() }}
{% javascripts
'@BaseBundle/Resources/js/main.js.twig'
%}
{% endjavascripts %}
{% endblock %}
< more template omitted >
And parts of main.js.twig:
function testFunction()
{
alert('{{VariableFromPHP}}');
}
And the controller:
/**
* @Route("/",name="home")
* @Template("MyBundle:Default:index.html.twig")
*/
public function indexAction()
{
return array( 'VariableFromPHP' => 'Hello World');
}
I expected the JavaScript to look like this at run-time:
alert('Hello World');
But, the code is unchanged. Any ideas what I am doing wrong?
Thanks, Scott