<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ES6 problem in 2.1.1 handlebar helper that worked fine in 1.8.2]]></title><description><![CDATA[<p>I have a handlebar helper function:</p>
<pre><code class="language-js">function SummarysForContact(map, name) { 
    var summary = &quot;&quot;;  
    var byname = map.get(name);
    byname.forEach(function(val, key) {
        summary += '&lt;h4&gt;Trouble # ' + key.toString() + &quot; - &quot; + val.Minutes + &quot; minutes &lt;/h4&gt;\r\n&quot;;
        summary += &quot;&lt;div&gt;\r\n&quot;;
        summary += val.Summary.replace(/(?:\r\n|\r|\n)/g, '&lt;br /&gt;');
        summary += &quot;&lt;/div&gt;\r\n&lt;hr/&gt;&quot;;
    });

    return summary;
}
</code></pre>
<p>The first parameter is an ES6 Map - works fine in 1.8.2 .NET embedded - does not work in 2.1.1 native node version.  Give this following error:</p>
<pre><code>Error while executing templating engine. map.get is not a function. Error on line 3:22.

  1 | function SummarysForContact(map, name) { 
  2 |     var summary = &quot;&quot;;  
&gt; 3 |     var byname = map.get(name);
    |                      ^
  4 |     byname.forEach(function(val, key) {
  5 |         summary += '&lt;h4&gt;Trouble # ' + key.toString() + &quot; - &quot; + val.Minutes + &quot; minutes &lt;/h4&gt;\r\n&quot;;
  6 |         summary += &quot;&lt;div&gt;\r\n&quot;;
</code></pre>
]]></description><link>https://forum.jsreport.net/topic/644/es6-problem-in-2-1-1-handlebar-helper-that-worked-fine-in-1-8-2</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 05:12:59 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/644.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 03 Aug 2018 23:52:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ES6 problem in 2.1.1 handlebar helper that worked fine in 1.8.2 on Sun, 05 Aug 2018 11:43:01 GMT]]></title><description><![CDATA[<p>I have a handlebar helper function:</p>
<pre><code class="language-js">function SummarysForContact(map, name) { 
    var summary = &quot;&quot;;  
    var byname = map.get(name);
    byname.forEach(function(val, key) {
        summary += '&lt;h4&gt;Trouble # ' + key.toString() + &quot; - &quot; + val.Minutes + &quot; minutes &lt;/h4&gt;\r\n&quot;;
        summary += &quot;&lt;div&gt;\r\n&quot;;
        summary += val.Summary.replace(/(?:\r\n|\r|\n)/g, '&lt;br /&gt;');
        summary += &quot;&lt;/div&gt;\r\n&lt;hr/&gt;&quot;;
    });

    return summary;
}
</code></pre>
<p>The first parameter is an ES6 Map - works fine in 1.8.2 .NET embedded - does not work in 2.1.1 native node version.  Give this following error:</p>
<pre><code>Error while executing templating engine. map.get is not a function. Error on line 3:22.

  1 | function SummarysForContact(map, name) { 
  2 |     var summary = &quot;&quot;;  
&gt; 3 |     var byname = map.get(name);
    |                      ^
  4 |     byname.forEach(function(val, key) {
  5 |         summary += '&lt;h4&gt;Trouble # ' + key.toString() + &quot; - &quot; + val.Minutes + &quot; minutes &lt;/h4&gt;\r\n&quot;;
  6 |         summary += &quot;&lt;div&gt;\r\n&quot;;
</code></pre>
]]></description><link>https://forum.jsreport.net/post/3216</link><guid isPermaLink="true">https://forum.jsreport.net/post/3216</guid><dc:creator><![CDATA[MolallaComm]]></dc:creator><pubDate>Sun, 05 Aug 2018 11:43:01 GMT</pubDate></item><item><title><![CDATA[Reply to ES6 problem in 2.1.1 handlebar helper that worked fine in 1.8.2 on Invalid Date]]></title><description><![CDATA[<p>Try to print out what is the <code>map</code> parameter.<br />
How do you pass it to the helper function?</p>
<p>There should me no change regarding this in v1.8.2 =&gt; v2.1.1</p>
]]></description><link>https://forum.jsreport.net/post/3219</link><guid isPermaLink="true">https://forum.jsreport.net/post/3219</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to ES6 problem in 2.1.1 handlebar helper that worked fine in 1.8.2 on Invalid Date]]></title><description><![CDATA[<p>The simplest template/script/helper I could make to reproduce:</p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;<br />
&lt;link rel=&quot;stylesheet&quot; href=&quot;<a href="https://cdn.rawgit.com/olton/Metro-UI-CSS/master/build/css/metro.min.css" rel="nofollow">https://cdn.rawgit.com/olton/Metro-UI-CSS/master/build/css/metro.min.css</a>&quot;&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;</p>
<pre><code>&lt;!--{{Summarys}}--&gt;
{{#each Contacts}}
&lt;h4 style='page-break-before: always;'&gt;{{ContactName}} - {{NumMinutes}} minutes on {{NumTickets}} tickets&lt;/h4&gt;
{{{SummarysForContact ../Summarys ContactName}}}
{{/each}}    
</code></pre>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>function SummarysForContact(map, name) {<br />
var summary = &quot;&quot;;</p>
<pre><code>summary += `&lt;p&gt;map = ${map}, name = ${name}&lt;/p&gt;`;
/*
var byname = map.get(name);
byname.forEach(function(val, key) {
    summary += `&lt;p&gt;key = ${key}, val = ${val}&lt;/p&gt;`;
});
*/

return summary;
</code></pre>
<p>}</p>
<p>function beforeRender(req, res, done) {<br />
req.data.Contacts = [{ ContactName: &quot;User1&quot;, NumMinutes: 100, NumTickets: 11}, { ContactName: &quot;User2&quot;, NumMinutes: 200, NumTickets: 21 }];<br />
req.data.Summarys = new Map();</p>
<pre><code>var submap1 = new Map();  
submap1.set(11, &quot;description for 11&quot;); 
submap1.set(12, &quot;description for 12&quot;);
req.data.Summarys.set(&quot;User1&quot;, submap1);

var submap2 = new Map();
submap2.set(21, &quot;description for 21&quot;); 
submap2.set(22, &quot;descripton for 22&quot;);
req.data.Summarys.set(&quot;User2&quot;, submap2);

done();
</code></pre>
<p>}</p>
]]></description><link>https://forum.jsreport.net/post/3224</link><guid isPermaLink="true">https://forum.jsreport.net/post/3224</guid><dc:creator><![CDATA[MolallaComm]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to ES6 problem in 2.1.1 handlebar helper that worked fine in 1.8.2 on Invalid Date]]></title><description><![CDATA[<p>The default config file sets up jsreport to evaluate templating engines in extra process. This means we serialize and deserialize data when running stcript or templating engine. This means we loose types like map in this process.</p>
<p>To make your code working you can configure jsreport to run scripts and templating engines in the same process as the whole application.</p>
<pre><code class="language-js">{
&quot;templatingEngines&quot;: {
    &quot;timeout&quot;: 10000,
    &quot;strategy&quot;: &quot;in-process&quot;
  }
}
</code></pre>
<p>Another option is to avoid using extra types like Map which cannot be simply serialized/deserialized.<br />
In this case you can probably use simple plain object.</p>
]]></description><link>https://forum.jsreport.net/post/3226</link><guid isPermaLink="true">https://forum.jsreport.net/post/3226</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to ES6 problem in 2.1.1 handlebar helper that worked fine in 1.8.2 on Invalid Date]]></title><description><![CDATA[<p>Thanks for following up on this - sure enough using plain old object fixed it!  I think i used map originally just to see if newer ES5/6 stuff worked which i guess it does minus this serialization issue.</p>
]]></description><link>https://forum.jsreport.net/post/4381</link><guid isPermaLink="true">https://forum.jsreport.net/post/4381</guid><dc:creator><![CDATA[MolallaComm]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>