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

413
Vistas
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 Respuestas
Responde la pregunta

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 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