<?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[Asset helper complains about wrong spec]]></title><description><![CDATA[<p>See the following playground <a href="https://playground.jsreport.net/studio/workspace/HJclQzyiM/22" rel="nofollow">here</a>, I have a helper for picking what asset to draw, however jsreport complains about the param spec being wrong.</p>
<p>The first two each statements demonstrate that the helper returns a string as expected and that the assets can be found:</p>
<pre><code>{{#each samples as |sample i|}}
{{getLevelImage sample}}
{{/each}}
{{#each samples as |sample i|}}
&lt;img src=&quot;{#asset slyk-alert.svg @encoding=dataURI}&quot; style=&quot;height:1.75%; margin: 0 auto;&quot;&gt;
{{/each}}
</code></pre>
<p>Where the helper <code>getLevelImage</code> is:</p>
<pre><code>handlebars.registerHelper(&quot;getLevelImage&quot;, function(sample)
{
  switch (sample.Results.Level) {
    case 1:
      return 'slyk-normal.svg @encoding=dataURI';
    case 2:
      return 'slyk-warning.svg @encoding=dataURI';
    case 3:
      return 'slyk-alert.svg @encoding=dataURI';
    case 4:
      return 'slyk-critical.svg @encoding=dataURI';
    default:
      return 'slyk-normal.svg @encoding=dataURI';
  }
});
</code></pre>
<p>This results in:</p>
<p><img src="/uploads/files/1522636842751-upload-15361a6e-73d3-4ff8-85d7-d8dab0e74183.png" alt="0_1522636840186_upload-15361a6e-73d3-4ff8-85d7-d8dab0e74183" class="img-responsive img-markdown" /><br />
But the final line throws the error.<br />
<img src="/uploads/files/1522636892192-upload-b41d0c60-9ef7-4031-a5ff-7c553d06aac4-resized.png" alt="0_1522636889324_upload-b41d0c60-9ef7-4031-a5ff-7c553d06aac4" class="img-responsive img-markdown" /></p>
]]></description><link>https://forum.jsreport.net/topic/466/asset-helper-complains-about-wrong-spec</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 04:06:31 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/466.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Apr 2018 02:41:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Asset helper complains about wrong spec on Mon, 02 Apr 2018 03:42:40 GMT]]></title><description><![CDATA[<p>See the following playground <a href="https://playground.jsreport.net/studio/workspace/HJclQzyiM/22" rel="nofollow">here</a>, I have a helper for picking what asset to draw, however jsreport complains about the param spec being wrong.</p>
<p>The first two each statements demonstrate that the helper returns a string as expected and that the assets can be found:</p>
<pre><code>{{#each samples as |sample i|}}
{{getLevelImage sample}}
{{/each}}
{{#each samples as |sample i|}}
&lt;img src=&quot;{#asset slyk-alert.svg @encoding=dataURI}&quot; style=&quot;height:1.75%; margin: 0 auto;&quot;&gt;
{{/each}}
</code></pre>
<p>Where the helper <code>getLevelImage</code> is:</p>
<pre><code>handlebars.registerHelper(&quot;getLevelImage&quot;, function(sample)
{
  switch (sample.Results.Level) {
    case 1:
      return 'slyk-normal.svg @encoding=dataURI';
    case 2:
      return 'slyk-warning.svg @encoding=dataURI';
    case 3:
      return 'slyk-alert.svg @encoding=dataURI';
    case 4:
      return 'slyk-critical.svg @encoding=dataURI';
    default:
      return 'slyk-normal.svg @encoding=dataURI';
  }
});
</code></pre>
<p>This results in:</p>
<p><img src="/uploads/files/1522636842751-upload-15361a6e-73d3-4ff8-85d7-d8dab0e74183.png" alt="0_1522636840186_upload-15361a6e-73d3-4ff8-85d7-d8dab0e74183" class="img-responsive img-markdown" /><br />
But the final line throws the error.<br />
<img src="/uploads/files/1522636892192-upload-b41d0c60-9ef7-4031-a5ff-7c553d06aac4-resized.png" alt="0_1522636889324_upload-b41d0c60-9ef7-4031-a5ff-7c553d06aac4" class="img-responsive img-markdown" /></p>
]]></description><link>https://forum.jsreport.net/post/2320</link><guid isPermaLink="true">https://forum.jsreport.net/post/2320</guid><dc:creator><![CDATA[Mika571]]></dc:creator><pubDate>Mon, 02 Apr 2018 03:42:40 GMT</pubDate></item><item><title><![CDATA[Reply to Asset helper complains about wrong spec on Invalid Date]]></title><description><![CDATA[<p>Handlebars does escaping if you call helper using <code>{{foo}}</code>. This breaks the asset specification. Try it with <code>{#asset {{{getLevelImage sample}}}}</code>.</p>
<p>FYI Are you aware that helpers in jsreport can be specified using global function? Calling <code>registerHelper</code> is not required.</p>
<pre><code class="language-js">function getLevelImage(sample) {
  return 'foo'
}</code></pre>
]]></description><link>https://forum.jsreport.net/post/2321</link><guid isPermaLink="true">https://forum.jsreport.net/post/2321</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Asset helper complains about wrong spec on Invalid Date]]></title><description><![CDATA[<p>Of course, thanks Jan!</p>
]]></description><link>https://forum.jsreport.net/post/2322</link><guid isPermaLink="true">https://forum.jsreport.net/post/2322</guid><dc:creator><![CDATA[Mika571]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Asset helper complains about wrong spec on Mon, 02 Apr 2018 12:07:57 GMT]]></title><description><![CDATA[<p>I did have another question, I have created the templates I needed using a jsreport-cli project, but I wanted to use jsreport in my existing node.js application. Do I need jsreport or to extend jsreport-core with the recipes and engine i want to use?<br />
edit: Would you prefer I create a new post?</p>
]]></description><link>https://forum.jsreport.net/post/2323</link><guid isPermaLink="true">https://forum.jsreport.net/post/2323</guid><dc:creator><![CDATA[Mika571]]></dc:creator><pubDate>Mon, 02 Apr 2018 12:07:57 GMT</pubDate></item><item><title><![CDATA[Reply to Asset helper complains about wrong spec on Invalid Date]]></title><description><![CDATA[<p>hi! you can use jsreport in your existing node.js application normally, this link would be helpful to you: <a href="https://jsreport.net/learn/adapting-jsreport" rel="nofollow">https://jsreport.net/learn/adapting-jsreport</a> , it contains section of how to integrate with express server in your app too.</p>
]]></description><link>https://forum.jsreport.net/post/2324</link><guid isPermaLink="true">https://forum.jsreport.net/post/2324</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>