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

133
Views
Render html with templating engine and injecting into 3rd party product

Working with a 3rd party product I can manipulate the dom using javascript inside the product. I can do sort of:

var foo = document.getElementById("foo");
var listItem = document.createElement("li");
foo.appendChild(listItem);
//etc...

This gets pretty messy fast. I'd like to use a html templating engine, but when I investigate alternative all assumes I have "control" over the html, which I don't.

I'd like to render/build html, javascript using an engine and then inject it into the 3rd party product.

Any suggestions?

(My apologies if the question is unclear. I'm not sure what I'm looking for)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I've figured out what I was looking for: client side javascript template engine!

Here's an example using ejs:

  let ejs = require('ejs');

  let data = ['geddy', 'neil', 'alex'];

  let template = `<ul>
                    <% for(let i = 0; i < people.length; i++) { %>
                        <li>
                           <%= people[i] %>
                        </li>
                    <% } %>
                  </ul>
                `;

  let html = ejs.render(template, {people: data});

  var foo = document.getElementById("foo");
  
  foo.innerHTML = html;

Hope this helps someone in the future. Happy coding!

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!