I am using EJS templates with CanJS and are looking for a way to debug my EJS code. Currently firebug can show me the syntax errors in EJS but in other browsers, I am not able to see anything.I need to go through my EJS file very carefully to solve the errors. I searched on web and found out about ejs_fulljslint / , but not able to run this properly. I included the script into my HTML file but still wasn't getting any console errors. I am not able to find a demo of debugging on web.
Can anyone tell me how to debug my EJS code. If you can provide me any example, that will be highly appreciated.
I am using EJS templates with CanJS and are looking for a way to debug my EJS code. Currently firebug can show me the syntax errors in EJS but in other browsers, I am not able to see anything.I need to go through my EJS file very carefully to solve the errors. I searched on web and found out about ejs_fulljslint https://code.google.com/p/embeddedjavascript/ , but not able to run this properly. I included the script into my HTML file but still wasn't getting any console errors. I am not able to find a demo of debugging on web.
Can anyone tell me how to debug my EJS code. If you can provide me any example, that will be highly appreciated.
Share Improve this question edited Mar 22, 2014 at 20:52 Ankur Aggarwal asked Mar 20, 2014 at 20:47 Ankur AggarwalAnkur Aggarwal 3,1015 gold badges33 silver badges57 bronze badges 7 | Show 2 more comments2 Answers
Reset to default 15In the end, EJS just translates to JavaScript and therefore just placing a debugger; statement where you need it and opening developer tools, might do the trick for you. For example, to check on the i variable in a for loop you would place your debugger; like this:
<script type="text/ejs" id="todoList">
<% for(var i = 0; i < todos.length; ++i) { %>
<% debugger; %>
<li><%= this[i].attr('description') </li>
<% } %>
</script>
I always try to avoid doing serious calculation in ejs but one way to start is to check all of the arguments of can.view
in the debugger before it enters the canjs. I find that I can usually figure out the issue from there.
ejs_jslint.js
for the hint of the error? – Just code Commented Mar 26, 2014 at 12:57