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

122
Visualizações
foreach external template html

I have searched on the internet, but I can't find the right syntax in javascript or jquery "finally if it's possible" to do for example ->

test.js

array = {title: 'hihihi',
         Name: 'hahaha',};

array.forEach((array) => { var template = load('test.html')});
    $("#ok").html(template);

test.html

<div id="test">${array.title}</div>

index.html

<div id="ok"></div>

is it possible to do this or not?

UPDATE

here is the solution I found:

test.js

    async function writeTemp(arg) {
    var template = "";
        template = await (await fetch('test.html')).text();
            template = eval("`" + template + "`");
            Object.keys(arg).forEach(prez => {
                template;
            });
            $("#ok").html(template);
    }

writeTemp(array);

test.html

<div id="test">${arg.title}</div>

index.html

<div id="ok"></div>

Thanks in advance.

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

0

I know eval is not much liked but this seems to be the only solution to your question.

var array = {
    title: 'hihihi',
    Name: 'hahaha',
};

var template = load('test.html')

template = eval("`" + template + "`");

$("#ok").html(template);
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