title: Play! Framework Access a Play variable from Javascript
body: <p>I'm new to the Play framework (1.2) but I was wondering and hopefully I phrase this question correctly....I have a Play variable which stores which section ("_section") of a page the user is currently viewing. Is there any way to access that variable from a .js function? </p>
  
  <p>UPDATE:</p>
  
  <pre><code>You can store objects for js as well from play:
  
  
      &lt;script type="text/javascript"&gt;
            window.mytestarray = new Array();
       &lt;/script&gt;
  
  
  
         #{list 0..links.size()-1, as:'i'}
  
  
  
     {%
      router = play.mvc.Router;
      url = router.reverse(_section + '.' + links[i]).url;
     %}
  
  
        &lt;script  type="text/javascript"&gt;
             window.mytestarray.push("${url}")
        &lt;/script&gt;
  
  
     &lt;li js_sub_nav_name="${ _section}" &gt;  &lt;!-- MC class="#{if i == 0}first#{/if}"--&gt;
     &lt;a href="${url}" class="${lines[i]}#{if _page == links[i]} active#{/if}"&gt;&amp;{'header.nav.'+_section+'.'+links[i]+'.html'}&lt;/a&gt;
  
     &lt;/li&gt;
    #{/list}
    &lt;/ul&gt;
   #{/if}
  </code></pre>