I have been trying this create a to do list using ejs and applying it in html. But Failing to get the result.
CODE Snippet:
<ul>
<li>Food Items</li>
<li>Play Cricket</li>
<li>Learn To code</li>
<li>Apply for jobs</li>
<li>Play game of Chess</li>
<% for(int i = 0;i<new_item.length;i ) %>
<% { %>
<li> <%= new_item %> </li>
<% } %>
</ul>
Error Getting:
SyntaxError: Unexpected identifier in I:\Complete Web Development Course\EJS\To Do List\views\list.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass `async: true` as an option.
at new Function (<anonymous>)
at Template.compile (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:673:12)
at Object.compile (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:398:16)
at handleCache (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:235:18)
at tryHandleCache (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:274:16)
at View.exports.renderFile [as engine] (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:491:10)
at View.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\view.js:135:8)
at tryRender (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\application.js:657:10)
at Function.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\application.js:609:3)
at ServerResponse.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\response.js:1039:7)
CodePudding user response:
for(int i = 0;i<new_item.length;i )
int
is not a valid type declaration in ejs so you should use let
or var
instead.