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

255
Views
No se puede anidar backlint (`) en html

En realidad, estoy usando nodemailer para enviar el código de plantilla html en el nodo js, pero el problema al que me enfrento es que no puedo anidar backlint en él:

Mi código:-

 let mailDetails={ from: 'def@gmail.com', to: 'abc@gmail.com', subject: 'Order Confirmation Mail', html: `<html> //outer backlint start from here <body> <p id="s"></p> <script> const dataElement = document.querySelector('s'); const data = [ {url: "https://images.unsplash.com/photo-1593642633279-1796119d5482?ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=60", name: 'Nathan', price: 'Rs. 250', description: 'IRAN'}, {url: "https://images.unsplash.com/photo-1593642633279-1796119d5482?ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=60", name: 'Nathan', price: 'Rs. 250', description: 'IRAN'}, ]; data.map(item => { dataElement.insertAdjacentHTML('beforebegin', `<p>${item.name}</p>`)});//inner backlints </script> </body> </body> </html> `, //outer backlint end };

Ps: - ignore los contenidos insertados por javascript ya que son datos ficticios. Solo quería mostrar el tipo de anidamiento que quería. Si uso ` entonces item.name queda indefinido e incluso al usar ${} sucedió.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Tienes que escapar del acento grave con \ . Este seria el resultado:

 <html> //outer backlint start from here <body> <p id="s"></p> <script> const dataElement = document.querySelector('s'); const data = [ {url: "https://images.unsplash.com/photo-1593642633279-1796119d5482?ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=60", name: 'Nathan', price: 'Rs. 250', description: 'IRAN'}, {url: "https://images.unsplash.com/photo-1593642633279-1796119d5482?ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=60", name: 'Nathan', price: 'Rs. 250', description: 'IRAN'}, ]; data.map(item => { dataElement.insertAdjacentHTML('beforebegin', \`<p>${item.name}</p>\`)});//inner backlints </script> </body> </body> </html>

Además, debe eliminar el segundo </body>

about 4 years ago · Juan Pablo Isaza Report

0

Hacer uso de ejs https://www.npmjs.com/package/ejs hará que dichas plantillas sean realmente rápidas. Lo estoy haciendo usando ejs.

ejemplo.js

 let mailDetails = { from: 'def@gmail.com', to: 'abc@gmail.com', subject: 'Order Confirmation Mail', html: ejs.render("<path_to_ejs_template/template.ejs>"), //<-- replace this line with correct path to template.ejs };

plantilla.ejs

 <html> <body> <p id="s"></p> <script> const dataElement = document.querySelector("s"); const data = [ { url: "https://images.unsplash.com/photo-1593642633279-1796119d5482?ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=60", name: "Nathan", price: "Rs. 250", description: "IRAN", }, { url: "https://images.unsplash.com/photo-1593642633279-1796119d5482?ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=60", name: "Nathan", price: "Rs. 250", description: "IRAN", }, ]; data.map((item) => { dataElement.insertAdjacentHTML("beforebegin", `<p>${item.name}</p>`); }); </script> </body> </html>
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!