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

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

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