javascript - How to comment ejs code ( JS node) -
i have code in ejs file.
<table> <% for(var i=0; < data.length; i++) { %> <tr> <td><%= data[i].id %></td> <td><%= data[i].name %></td> </tr> <% } %> </table>
when comment way,
<!-- <table> --> <!-- <% for(var i=0; < data.length; i++) { %> --> <!-- <tr> --> <!-- <td><%= data[i].id %></td> --> <!-- <td><%= data[i].name %></td> --> <!-- </tr> --> <!-- <% } %> --> <!-- </table> -->
i still have error in line 2. here stack of error
referenceerror: c:\users\toumi\desktop\workspaces\eclipse\todolist\views\x.ejs:2 1| <!-- <table> --> >> 2| <!-- <% for(var i=0; < data.length; i++) { %> --> 3| <!-- <tr> --> 4| <!-- <td><%= data[i].id %></td> --> 5| <!-- <td><%= data[i].name %></td> --> data not defined @ eval (eval @ <anonymous> (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\ejs\lib\ejs.js:455:12), <anonymous>:11:25) @ c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\ejs\lib\ejs.js:482:14 @ view.exports.renderfile [as engine] (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\ejs\lib\ejs.js:348:31) @ view.render (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\express\lib\view.js:93:8) @ eventemitter.app.render (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\express\lib\application.js:566:10) @ serverresponse.res.render (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\express\lib\response.js:938:7) @ c:\users\toumi\desktop\workspaces\eclipse\todolist\todolist.js:13:6 @ layer.handle [as handle_request] (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\express\lib\router\layer.js:82:5) @ next (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\express\lib\router\route.js:110:13) @ route.dispatch (c:\users\toumi\desktop\workspaces\eclipse\todolist\node_modules\express\lib\router\route.js:91:3)
how can comment code ?
there 2 solutions:
<%# comment %>
( it's documentation )<%/* comment */%>
( works it's pretty ugly , uncomfortable use )
i don't see difference between examples except highlighting syntax in ide ( example brackets ide )
Comments
Post a Comment