title: Can a script tag get an EJS variable?
body: <p>I'm building an app with a NodeJS backend and EJS. I want to create a map with some markers. Those markers are some names of cities and countries from database. My question is: can I somehow use that EJS &lt;%= %> into a script tag ? I did something, but my IDE throws me an error. And if It's possible can you please show me how?</p>
  
  <p>Here are my functions:</p>
  
  <p>NODE JS </p>
  
  <pre><code>exports.getMap =  (req,res,next) =&gt; {
  
      const notename = req.params.notename;
    Note.findOne({notename:notename}).then(note =&gt; {
  
      res.render('feed/map', {
          pageTitle:'Pedigree Notes | MAP',
          path:'/getmap',
          locations:note.locations
  
        });
    })
  
  
  }
  </code></pre>
  
  <p>AND THE CLIENT SIDE</p>
  
  <pre><code>&lt;%- include('../includes/head.ejs'); %&gt;
  &lt;%- include('../includes/navigation.ejs');%&gt;
  
  &lt;main&gt;
  &lt;div class="container-fluid"&gt;
  
      &lt;div id="map"&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  var map;
  var geocoder;
  function initMap(){
     var mapLayer = document.getElementById('map')
     var centerCoordinates = new google.maps.LatLng(40.4637, 3.7492);
     var defaultOptions = { center:centerCoordinates, zoom:2};
  
     map = new google.maps.Map(mapLayer,defaultOptions);
     geocoder = new google.maps.Geocoder();
     &lt;% for(let location of locations) { %&gt;
     &lt;% } %&gt;
  
  }
  &lt;/script&gt;
  &lt;script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC8QqwujgKgEaAk2_MvUph9Jows_P1eILs&amp;callback=initMap"
  async defer&gt;&lt;/script&gt;
  &lt;/main&gt;
  
  &lt;%- include('../includes/end.ejs'); %&gt;
  </code></pre>
  
  <p>How can I wrote that for to reach the values parsed from backend?</p>
  
  <p>Thank you!</p>