I get the console error below, due to the lines marked with #Begin and End of lines causing errors
Uncaught TypeError: frappe.template.compile(…) is not a function
at Object.frappe.render (microtemplate.js:74)
at Object.frappe.render_template (microtemplate.js:85)
at Object.frappe.render_grid (microtemplate.js:105)
at QueryReport.print_report (query_report.js:1007)
at query_report.js:1201
at print.js:538
at frappe.ui.Dialog. (messages.js:76)
at HTMLButtonElement. (dialog.js:141)
at HTMLButtonElement.dispatch (jquery.min.js:3)
at HTMLButtonElement.r.handle (jquery.min.js:3)
If you check this link: Template Designer Documentation — Jinja Documentation (2.11.x) you’ll notice that you’re not using the right syntax.
Jinja isn’t JS, it has his own way of doing things. Ex: to define a variable, you need to use ‘set’ instead of ‘var’, the foreach can/need be use with list directly (instead of incrementing it manually), you need to close the if/for condition with {% endif %} or {% endfor %}, …
In fact, Jinja syntax looks like Python.
I think I might have mislabeled this to Jinja, because this code I just copied from an existing report in ERPNext and edited. It works well, until I introduce the lines below.
#Begin of lines causing errors
{% set company_tax_id = frappe.db.get_value(‘Company’, {%= filters.company %}, [‘tax_id’]) %}
@glz Although the same commands are use to render the templates in js client side and python server side frappe.render_template
but they work differently. If you want to use jinja template use the server side rendering. JS side rendering has a limited scope.