<?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[EJS child template parameter]]></title><description><![CDATA[<p>I tried a simple parent/child template with ejs rendering engine  but could not find a way to pass data to child template.</p>
<p>I am new to jsreport and your advise will be helpful. Thanks.</p>
<p>Ivan</p>
<p>parent template (ejs, text)</p>
<pre><code>&lt;head&gt;
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;    
&lt;/head&gt;

&lt;% if (items) { %&gt;
&lt;table class='invoice-box'&gt;
    &lt;tr class=&quot;headerrow&quot;&gt;
        &lt;th&gt;name&lt;/th&gt;
        &lt;th&gt;amount&lt;/th&gt;
        &lt;th&gt;child template&lt;/th&gt;
    &lt;/tr&gt;
    &lt;% items.forEach( function(item) { %&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;%= item.name %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= item.amount %&gt;&lt;/td&gt;
        &lt;td&gt;
            &lt;% if (item.details) { %&gt;
            {#child test-1-child-1 @data.child.id=&lt;%= item.id %&gt; }
            &lt;% } else { %&gt;
            no details
            &lt;% } %&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;% }) %&gt;
&lt;/table&gt;  
&lt;% } else { %&gt;
no result
&lt;% } %&gt;
</code></pre>
<p>child template (ejs, text)</p>
<pre><code>&lt;div&gt;child.id&lt;/div&gt;
&lt;div&gt;&lt;%= child.id %&gt;&lt;/div&gt;
</code></pre>
<p>sample data</p>
<pre><code>{
    &quot;items&quot;: [{
        &quot;id&quot;: 1,
        &quot;name&quot;: &quot;abc&quot;,
        &quot;amount&quot;: 1234.56,
        &quot;details&quot;: [{
            &quot;id&quot;: 1,
            &quot;description&quot;: &quot;line 1&quot;
        }, {
            &quot;id&quot;: 2,
            &quot;description&quot;: &quot;line 2&quot;
        }]
    }]
}
</code></pre>
<p>However, <a href="http://child.id" rel="nofollow">child.id</a> was not shown.  Please see the output below.</p>
<pre><code>&lt;head&gt;
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;    
&lt;/head&gt;


&lt;table class='invoice-box'&gt;
    &lt;tr class=&quot;headerrow&quot;&gt;
        &lt;th&gt;name&lt;/th&gt;
        &lt;th&gt;amount&lt;/th&gt;
        &lt;th&gt;child template&lt;/th&gt;
    &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td&gt;abc&lt;/td&gt;
        &lt;td&gt;1234.56&lt;/td&gt;
        &lt;td&gt;
            
            &lt;div&gt;child.id&lt;/div&gt;
&lt;div&gt;&amp;lt;%&lt;/div&gt;

            
        &lt;/td&gt;
    &lt;/tr&gt;
    
&lt;/table&gt;  
</code></pre>
]]></description><link>https://forum.jsreport.net/topic/411/ejs-child-template-parameter</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 15:57:30 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/411.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 Feb 2018 02:05:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to EJS child template parameter on Invalid Date]]></title><description><![CDATA[<p>I tried a simple parent/child template with ejs rendering engine  but could not find a way to pass data to child template.</p>
<p>I am new to jsreport and your advise will be helpful. Thanks.</p>
<p>Ivan</p>
<p>parent template (ejs, text)</p>
<pre><code>&lt;head&gt;
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;    
&lt;/head&gt;

&lt;% if (items) { %&gt;
&lt;table class='invoice-box'&gt;
    &lt;tr class=&quot;headerrow&quot;&gt;
        &lt;th&gt;name&lt;/th&gt;
        &lt;th&gt;amount&lt;/th&gt;
        &lt;th&gt;child template&lt;/th&gt;
    &lt;/tr&gt;
    &lt;% items.forEach( function(item) { %&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;%= item.name %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= item.amount %&gt;&lt;/td&gt;
        &lt;td&gt;
            &lt;% if (item.details) { %&gt;
            {#child test-1-child-1 @data.child.id=&lt;%= item.id %&gt; }
            &lt;% } else { %&gt;
            no details
            &lt;% } %&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;% }) %&gt;
&lt;/table&gt;  
&lt;% } else { %&gt;
no result
&lt;% } %&gt;
</code></pre>
<p>child template (ejs, text)</p>
<pre><code>&lt;div&gt;child.id&lt;/div&gt;
&lt;div&gt;&lt;%= child.id %&gt;&lt;/div&gt;
</code></pre>
<p>sample data</p>
<pre><code>{
    &quot;items&quot;: [{
        &quot;id&quot;: 1,
        &quot;name&quot;: &quot;abc&quot;,
        &quot;amount&quot;: 1234.56,
        &quot;details&quot;: [{
            &quot;id&quot;: 1,
            &quot;description&quot;: &quot;line 1&quot;
        }, {
            &quot;id&quot;: 2,
            &quot;description&quot;: &quot;line 2&quot;
        }]
    }]
}
</code></pre>
<p>However, <a href="http://child.id" rel="nofollow">child.id</a> was not shown.  Please see the output below.</p>
<pre><code>&lt;head&gt;
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;    
&lt;/head&gt;


&lt;table class='invoice-box'&gt;
    &lt;tr class=&quot;headerrow&quot;&gt;
        &lt;th&gt;name&lt;/th&gt;
        &lt;th&gt;amount&lt;/th&gt;
        &lt;th&gt;child template&lt;/th&gt;
    &lt;/tr&gt;
    
    &lt;tr&gt;
        &lt;td&gt;abc&lt;/td&gt;
        &lt;td&gt;1234.56&lt;/td&gt;
        &lt;td&gt;
            
            &lt;div&gt;child.id&lt;/div&gt;
&lt;div&gt;&amp;lt;%&lt;/div&gt;

            
        &lt;/td&gt;
    &lt;/tr&gt;
    
&lt;/table&gt;  
</code></pre>
]]></description><link>https://forum.jsreport.net/post/2045</link><guid isPermaLink="true">https://forum.jsreport.net/post/2045</guid><dc:creator><![CDATA[ivan_wang_hk]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to EJS child template parameter on Invalid Date]]></title><description><![CDATA[<p>hi! child templates can't recognize dynamic data passed as params when called like this.</p>
<p>however there is a workaround, and <a href="https://playground.jsreport.net/studio/workspace/H1qvwvQDG/11" rel="nofollow">here is an example</a> of how to apply it for your case</p>
]]></description><link>https://forum.jsreport.net/post/2073</link><guid isPermaLink="true">https://forum.jsreport.net/post/2073</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to EJS child template parameter on Invalid Date]]></title><description><![CDATA[<p>thank you so much for your reply. I will try the workaround.</p>
]]></description><link>https://forum.jsreport.net/post/2085</link><guid isPermaLink="true">https://forum.jsreport.net/post/2085</guid><dc:creator><![CDATA[ivan_wang_hk]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>