thank you so much for your reply. I will try the workaround.
ivan_wang_hk
@ivan_wang_hk
0
Reputation
2
Posts
731
Profile views
0
Followers
0
Following
Posts made by ivan_wang_hk
-
RE: EJS child template parameter
-
EJS child template parameter
I tried a simple parent/child template with ejs rendering engine but could not find a way to pass data to child template.
I am new to jsreport and your advise will be helpful. Thanks.
Ivan
parent template (ejs, text)
<head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> </head> <% if (items) { %> <table class='invoice-box'> <tr class="headerrow"> <th>name</th> <th>amount</th> <th>child template</th> </tr> <% items.forEach( function(item) { %> <tr> <td><%= item.name %></td> <td><%= item.amount %></td> <td> <% if (item.details) { %> {#child test-1-child-1 @data.child.id=<%= item.id %> } <% } else { %> no details <% } %> </td> </tr> <% }) %> </table> <% } else { %> no result <% } %>
child template (ejs, text)
<div>child.id</div> <div><%= child.id %></div>
sample data
{ "items": [{ "id": 1, "name": "abc", "amount": 1234.56, "details": [{ "id": 1, "description": "line 1" }, { "id": 2, "description": "line 2" }] }] }
However, child.id was not shown. Please see the output below.
<head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> </head> <table class='invoice-box'> <tr class="headerrow"> <th>name</th> <th>amount</th> <th>child template</th> </tr> <tr> <td>abc</td> <td>1234.56</td> <td> <div>child.id</div> <div><%</div> </td> </tr> </table>