i just wanna ask simple i have an error like this
Error: Could not find matching close tag for "<%=". at C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:693:19 at Array.forEach () at Template.generateSource (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:678:15) at Template.compile (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:557:12) at Object.compile (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:389:16) at handleCache (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:212:18) at tryHandleCache (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:251:16) at View.exports.renderFile [as engine] (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\ejs\lib\ejs.js:482:10) at View.render (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\express\lib\view.js:135:8) at tryRender (C:\Users\User\Documents\latihannode.js\nodejs8\library\node_modules\express\lib\application.js:640:10)
and this is that i used code using ejs
<ul class="nav navbar-nav">
<% for(let i=0; i<nav.length; i++) { %>
<li>
<a href="<%=nav[i].link"><%nav[i].title%></a>
</li>
<%}%>
</ul>
This is from my NodeJS js file. when i render the "index" i passed the index variable to EJS
app.get('/', (req, res) => {
res.render(
'index',
{
nav: [{ link: '/buku', title: 'Buku' },
{ link: '/penulis', title: 'Penulis' }],
title: 'library'
}
);
});
You should close href
with %>
.
<a href="<%=nav[i].link%>"><%nav[i].title%></a>