How to debug EJS code in Chrome / Safari

I am using EJS templates with CanJS and am looking for a way to debug my EJS code. Currently, firebug can show me syntax errors in EJS, but in other browsers, I can’t see anything. I need to go through my EJS file very carefully to resolve the errors. I searched the web and found out about ejs_fulljslint https://code.google.com/p/embeddedjavascript/ , but could not do it correctly. I included the script in my HTML file but still did not receive any console errors. I cannot find a debug demo on the Internet.

Can anyone tell me how to debug my EJS code. If you can provide me any example, this would be much appreciated.

+6
source share
2 answers

In the end, EJS just translates into JavaScript and therefore just puts the debugger statement where you need it, and opening developer tools can do the trick for you. For example, to check the variable i in a for loop, you put your debugger as follows:

<script type="text/ejs" id="todoList"> <% for(var i = 0; i < todos.length; ++i) { %> <% debugger; %> <li><%= this[i].attr('description') </li> <% } %> </script> 
+5
source

I always try to avoid serious calculations in ejs, but one way to get started is to check all the can.view arguments in the debugger before it goes into canjs. I find that I can usually find out this question.

0
source

All Articles