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

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

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