I would never use a <script></script> for that, in my projects I have this pattern:
<!-- Layout -->
<div id="config"
data-environment="..."
></div>
I always provide the current environment in the master layout, I have a config.jsfile with the right data for the right environment.
When I need to pass some data to my javascript I do something like that in my view:
<div id="app"
data-users="..."
data-zombies="..."
...
></div>
If you abstract that with some helpers (elixir side) you can do:
<%= App.Helpers.make_html(:app, [users: @users, zombies: @zombies]) %>
In the javascript side, when I load the page I just extract the data-attributes and set them in a variable options for the current controller:
class ZombieController extends Controller
setup: ->
console.log(@options) # I have all the data there.
# I can do
zombies = @options.zombies
Well, it's just an example and you should adapt that for your current project. The key is to abstract.
Hope it helps :)
<%= %>and then just retrieve it with Javascript. - NoDisplayName