最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Debug EJS code in ChromeSafari - Stack Overflow

programmeradmin3浏览0评论

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
  • Have u added ejs_jslint.js for the hint of the error? – Just code Commented Mar 26, 2014 at 12:57
  • @DholakiyaAnkit I added ejs_fulljslint.js from the above mentioned link but got nothing. Can you tell me more about ejs_jslint.js ? Any link to that – Ankur Aggarwal Commented Mar 26, 2014 at 12:59
  • ejs_jshint is the js which gives you a line no and exact error where you stuck and btw you don't know how to debug in chrome? – Just code Commented Mar 26, 2014 at 13:01
  • @DholakiyaAnkit I know how to debug javascript but I don't know how to debug EJS file in chrome. Also can you provide the link to ejs_jslint.js . Not able to find it on web – Ankur Aggarwal Commented Mar 26, 2014 at 13:07
  • 1 Is your js file included in a source code? When page is rendered – Just code Commented Mar 26, 2014 at 13:25
 |  Show 2 more comments

2 Answers 2

Reset to default 15

In 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.

发布评论

评论列表(0)

  1. 暂无评论