Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
EJS cant find a closing tag for some reason

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)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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>
<% } %>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda