Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda