<% if(items.length ){ %>
<h1> empty cart </h1 > <% }} %>
the above code is in my checkout .ejs file
app.get('/shop/checkout',(req,resp)=>{
resp.render('checkout',{items:cart});
this is my .js file in node . cart is an array in this file.
items is the argument which i have passed in my .js file while rendering
everything is working fine in my project. but when i add that above code .it shows this error.
i want to implement with the code that when my items. length is empty a heading show that “cart is empty”.
when i run the following error gets
SyntaxError: Missing catch or finally after try in C:\Users\AMIT SINGH\Desktop\music cart\views\checkout.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 (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\ejs\lib\ejs.js:618:12)
at Object.compile (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\ejs\lib\ejs.js:389:16)
at handleCache (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\ejs\lib\ejs.js:212:18)
at tryHandleCache (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\ejs\lib\ejs.js:251:16)
at View.exports.renderFile [as engine] (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\ejs\lib\ejs.js:482:10)
at View.render (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\express\lib\view.js:135:8)
at tryRender (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\express\lib\application.js:640:10)
at Function.render (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\express\lib\application.js:592:3)
at ServerResponse.render (C:\Users\AMIT SINGH\Desktop\music cart\node_modules\express\lib\response.js:1008:7)
please help