Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

416
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!