Reputation: 128
If the variable <%= active %> is mycontent I want to add a button
<% if (<%= active %> === "mycontent" ){ %>
<div class="myContent-container">
<button class="btn btn-main-bg">Create</button>
</div>
<% } %>
But the website says that
Error: Could not find matching close tag for "<%".
at C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:740:19
at Array.forEach (<anonymous>)
at Template.generateSource (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:730:15)
at Template.compile (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:585:12)
at Object.compile (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:396:16)
at handleCache (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:233:18)
at tryHandleCache (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:272:16)
at View.exports.renderFile [as engine] (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\ejs\lib\ejs.js:489:10)
at View.render (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\express\lib\view.js:135:8)
at tryRender (C:\Users\tlege\OneDrive\Masaüstü\Site(1.0)\node_modules\express\lib\application.js:640:10)
Upvotes: 0
Views: 458
Reputation: 128
The answer was so simple. All I had to do was to remove <%= and =%> from the code. Because its already a code block, it doesnt require extra ejs characters.
So the answer should be this:
<% if (active === "mycontent" ){ %>
<div class="myContent-container">
<button class="btn btn-main-bg">Create</button>
</div>
<% } %>
Upvotes: 1