Hi Team,
I am creating a custom page and when I try to use loop.index variable or range function in the template, I get a compilation error in the javascript on browser.
The template looks like
<ul>
{% for item in data %}
{% set loop_revindex = loop.index %}
<li>{{ loop_revindex }}</li>
{% endfor %}
</ul>
this gives an error which says
Unexpected identifier 'loop_revindex'
SyntaxError: Unexpected identifier 'loop_revindex'
at new Function (<anonymous>)
at frappe.template.compile (http://one.localhost:8000/assets/frappe/dist/js/desk.bundle.X36ZLV6H.js:38692:42)
at frappe.render (http://one.localhost:8000/assets/frappe/dist/js/desk.bundle.X36ZLV6H.js:38705:28)
at frappe.render_template (http://one.localhost:8000/assets/frappe/dist/js/desk.bundle.X36ZLV6H.js:38719:19)
at Object.callback (organization_archite.js:29:13)
at Object.callback [as success_callback] (http://one.localhost:8000/assets/frappe/dist/js/desk.bundle.X36ZLV6H.js:33662:21)
at 200 (http://one.localhost:8000/assets/frappe/dist/js/desk.bundle.X36ZLV6H.js:33698:39)
at Object.<anonymous> (http://one.localhost:8000/assets/frappe/dist/js/desk.bundle.X36ZLV6H.js:33840:11)
at fire (http://one.localhost:8000/assets/frappe/dist/js/libs.bundle.6XLVBACU.js:1751:39)
at Object.fireWith [as resolveWith] (http://one.localhost:8000/assets/frappe/dist/js/libs.bundle.6XLVBACU.js:1837:19)
The browser console logs
TypeError: frappe.template.compile(...) is not a function
at frappe.render (microtemplate.js:100:42)
at frappe.render_template (microtemplate.js:114:16)
at Object.callback (organization_archite.js:29:13)
at Object.callback [as success_callback] (request.js:85:16)
at 200 (request.js:128:34)
at Object.<anonymous> (request.js:294:6)
at fire (jquery.js:3500:31)
at Object.fireWith [as resolveWith] (jquery.js:3630:7)
at done (jquery.js:9796:14)
at XMLHttpRequest.<anonymous> (jquery.js:10057:9)
on using the template
<ul>
{% for i in range(0,10) %}
<li>{{ i }}</li>
{% endfor %}
</ul>
I get a similar error. Can someone please help…