title: Does EJS handle array.map(callback)?
body: <p>I am passing an array of objects to an EJS template, which I would like to map into links using the regular .map() method of arrays. But for reasons I can't figure out, the callback I'm passing to map() doesn't work within EJS the way I'd expect, and I'm getting empty results.</p>
  
  <p>My data is an array of objects, each with a "section" and a "name" key. This array is passed as "entries" to the template:</p>
  
  <pre><code>siteHeaders = [ { section: "home", name: "Home"}, 
                  { section: "about", name: "About Me"}, 
                  ... plus few more ]
  </code></pre>
  
  <p>The template looks like this, and I have it in a local variable called (surprise) <code>template</code>:</p>
  
  <pre><code>&lt;% entries = entries.map(function(elem) { -%&gt;
    &lt;% return -%&gt;
    &lt;a href="/&lt;%= elem.section %&gt;"&gt;
      &lt;%= elem.name %&gt;
    &lt;/a&gt;
  &lt;% } ) -%&gt;
  &lt;p&gt;&lt;%- entries.join(" | ") %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>The result of this template, when I call <code>require('ejs').render(template, {entries: siteHeaders})</code> is:</p>
  
  <pre><code>          &lt;p&gt; |  |  |  | &lt;/p&gt;
  </code></pre>
  
  <p>What I don't get is why this doesn't work in an EJS template, when the corresponding map call works just fine in REPL:</p>
  
  <pre><code>&gt; siteHeaders.map(function(e){ return '&lt;a href="/' + e.section +'"&gt;' + e.name + '&lt;/a&gt;' })
  [ '&lt;a href="/home"&gt;Home&lt;/a&gt;',
    '&lt;a href="/guide"&gt;About Me&lt;/a&gt;',
    '&lt;a href="/quickstart"&gt;Portfolio&lt;/a&gt;',
    '&lt;a href="/reference"&gt;Blog&lt;/a&gt;',
    '&lt;a href="/downloads"&gt;Contact&lt;/a&gt;' ]
  &gt;
  </code></pre>
  
  <p>Any clues?</p>