If you want to add variables in Javacsript you will have to inline the Javascript in the template file.