• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

98
Views
Node js Reemplace la tabla Html con datos daynamic

Estoy un poco atascado con la sustitución de cadenas en el archivo HTML mediante bucles en la matriz. Estoy leyendo el archivo HTML, es un archivo de plantilla grande adjunto al correo electrónico. Quiero hacer un bucle en los datos y reemplazar HTML con datos dinámicos. Pero solo un elemento está reemplazando.

 <table cellpadding="10" cellspacing="0" width="600" align="center" style="border-collapse:collapse;background:white;"> <tr> <td> <table cellpadding="0" cellspacing="0" width="600" align="left" border="1" id="myTable"> <tr> <td>Date</td> <td>%DateTo% - %DateFrom%</td> </tr> <tr> <td>Url</td> <td>%reportUrl%</td> </tr> </table> </td> </tr> </table> let mailHtml = ''; mailHtml = fs.readFileSync('app/emailTemplates/ReportTemplate .html').toString(); dataValues.forEach(ele => { mailHtml = mailHtml.replace('%DateTo%', ele.dateTo); mailHtml = mailHtml.replace('%DateFrom%', ele.dateFrom); mailHtml = mailHtml.replace('%reportUrl%', ele.reportUrl); })

ingrese la descripción de la imagen aquí

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error