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

415
Visualizações
ejs include with innerHTML

With the code below, the contents of car.ejs appears properly.

<div id="carHolder">
    <%- include('car.ejs') %>            
</div>

Then I want to include multiple car.ejs dynamically, so I tried this:

<script>
    document.getElementById("carHolder").innerHTML += "<%- include('car.ejs') %>";
</script>

But there is still only one car.ejs appearing. I also tried with empty div:

<div id="carHolder"></div>
<script>
    document.getElementById("carHolder").innerHTML = "<%- include('car.ejs') %>";
</script>

Then there's no car.ejs appearing at all. How to dynamically include ejs with innerHTML?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

ejs is a JavaScript library which allows you to render .ejs templates.
It must be rendered by the library.

A minimal example from their website ():

<script src="ejs.js"></script>
<script>
  let people = ['geddy', 'neil', 'alex'];
  let html = ejs.render('<%= people.join(", "); %>', {people: people});
</script>

In line 4 you see how you can render .ejs content on the fly within the browser.
But I doubt that include will for for the browser version.

A possible solution would be to load the content of car.ejs into a variable beforehand and just render that instead.

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