It seems that once you find yourself in javascript: slim-block, you also will not be able to execute ruby loop.
I was able to get this to work mostly
- @spots.each do |spot| javascript: map.addMarker({ lat:
but it makes separate script tags for each addMarker call, which seems pretty dumb.
You can also try placing the data on the page as JSON and then looping through Javascript. Something like that:
javascript: var spots = #{raw @spots.to_json}; var ii = 0; var nspots = spots.length; for(;ii<nspots;++ii) { theMap.addMarker(spots[ii]); }
You want theMap be available by the time this file is theMap , but I think this can do the trick. You should also check the JSON format for each @spot. Depending on how you configure JSON, each spot may look like
{'spot': { 'latitude':
which means you have to play the object in a loop.
source share