<?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[Component Evaluation Hook]]></title><description><![CDATA[<p>Hello,</p>
<p>I'm working on an in-house extension that would allow us to &quot;hot swap&quot; components of a report based on incoming context, i.e. one client might have a custom version of a component for a specific report stored elsewhere (not just the fs-store).</p>
<p>I've got a working version right now where I'm using the <code>beforeRenderListeners</code> hook to make the content swap <em>on disk</em> using the <code>documentStore.update</code> function and then reverting it back in the <code>afterRenderListeners</code> hook if an update was made.</p>
<p>This approach works, but I don't like the idea of modifying the component temporarily even if it is for a short period of time.  Is there a hook I'm missing which could be attached to the Component Evaluation event?  I've been through the <code>jsreport-components</code> code pretty thoroughly but I don't see how the evaluate call used by the proxy would trigger anything, but hopefully I'm missing something?</p>
<p>If this isn't present is it something that would make sense on the roadmap?  Ideally I would be able to intercept a pre-render of a component and modify the <code>req</code> on that specific call if needed and leave the <code>documentStore</code> alone.  Alternatively I suppose we could use child reports but that feels like a lot of extra overhead compared to just dynamic components.</p>
]]></description><link>https://forum.jsreport.net/topic/3506/component-evaluation-hook</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 04:23:06 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/3506.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Nov 2025 19:14:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Component Evaluation Hook on Invalid Date]]></title><description><![CDATA[<p>Hello,</p>
<p>I'm working on an in-house extension that would allow us to &quot;hot swap&quot; components of a report based on incoming context, i.e. one client might have a custom version of a component for a specific report stored elsewhere (not just the fs-store).</p>
<p>I've got a working version right now where I'm using the <code>beforeRenderListeners</code> hook to make the content swap <em>on disk</em> using the <code>documentStore.update</code> function and then reverting it back in the <code>afterRenderListeners</code> hook if an update was made.</p>
<p>This approach works, but I don't like the idea of modifying the component temporarily even if it is for a short period of time.  Is there a hook I'm missing which could be attached to the Component Evaluation event?  I've been through the <code>jsreport-components</code> code pretty thoroughly but I don't see how the evaluate call used by the proxy would trigger anything, but hopefully I'm missing something?</p>
<p>If this isn't present is it something that would make sense on the roadmap?  Ideally I would be able to intercept a pre-render of a component and modify the <code>req</code> on that specific call if needed and leave the <code>documentStore</code> alone.  Alternatively I suppose we could use child reports but that feels like a lot of extra overhead compared to just dynamic components.</p>
]]></description><link>https://forum.jsreport.net/post/14805</link><guid isPermaLink="true">https://forum.jsreport.net/post/14805</guid><dc:creator><![CDATA[jsnevely-tempest]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Component Evaluation Hook on Invalid Date]]></title><description><![CDATA[<p>Maybe you can implement your own helper &quot;dynamicComponent&quot; that receives the component code and returns the evaluated result.<br />
It would be up to you where you download the component implementation.</p>
<p><a href="https://playground.jsreport.net/w/anon/CQZ_3bC4" rel="nofollow">https://playground.jsreport.net/w/anon/CQZ_3bC4</a></p>
<pre><code>
const jsreport = require('jsreport-proxy')

async function dynamicComponent(content, helpers) {
    return await jsreport.templatingEngines.evaluate({
      engine: 'handlebars',
      content: content,
      helpers: helpers,
      data: this
    }, {
      entity: jsreport.req.template,
      entitySet: 'templates'
    })
}
</code></pre>
<pre><code>{{{dynamicComponent &quot;some dynamic content {{myData}}&quot; &quot;function aHelper() {}&quot;}}}
</code></pre>
]]></description><link>https://forum.jsreport.net/post/14807</link><guid isPermaLink="true">https://forum.jsreport.net/post/14807</guid><dc:creator><![CDATA[admin]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Component Evaluation Hook on Invalid Date]]></title><description><![CDATA[<p>Thanks for the follow-up, I like that idea because this way I wouldn't be polluting the default behavior of existing reports with components already.  I'll try this approach for sure!</p>
]]></description><link>https://forum.jsreport.net/post/14808</link><guid isPermaLink="true">https://forum.jsreport.net/post/14808</guid><dc:creator><![CDATA[jsnevely-tempest]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>