I am calling a html code with jinja tags and passing the values of child table but getting error
frappe.template.compile(...) is not a function
I know there’s some issue in my html but not getting it exactly.
Here’s the particular section where I am using jinjaa
{% for data in jinja %}
<tr>
<td align="left" style="padding:6px;">
{{data.name}}
</td>
<td align="center" style="padding:6px;">
{{data.action}}
</td>
<td align="center" style="padding:6px;">
{{data.lots}}
</td>
<td align="left" style="padding:6px;">
{{data.notes}}
</td>
</tr>
{% endfor %}
Here jinja is the name of child table (of single page doctype)
Also tried as
{% for (var i = 0; i < (cur_frm.doc.jinja).length; i++) { %}
<tr>
<td align="left" style="padding:6px;">
{% cur_frm.doc.jinja[i].name %}
</td>
<td align="center" style="padding:6px;">
{% cur_frm.doc.jinja[i].action %}
</td>
<td align="center" style="padding:6px;">
{% cur_frm.doc.jinja[i].lots %}
</td>
<td align="left" style="padding:6px;">
{% cur_frm.doc.jinja[i].notes %}
</td>
</tr>
{% } %}
This is my custom script:
frappe.ui.form.on("Jinja Test",{
refresh: function(frm){
frm.add_custom_button(__('Preview'), function() {
var a = $('input[name="Beta"]:checked').val();
var b
console.log(a)
frappe.call({
method:"frappe.client.get_value",
args: {
doctype:"Email Template",
filters: { subject: a },
fieldname: ['code'],
},
async: false,
callback: function(res){
if(res.message!=undefined){
b = res.message.code
}else { }
}
});
if(b!=undefined){
var data = frm.doc.jinja
console.log(data)
}
var z = frappe.render_template(b)
var newtab = window.open();
newtab.document.write(z);
});
}
});
Note, I have created a custom field of type code in Email Template
Any help will be hugely appreciated.