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

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

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