function domHTML(script, contact = {}, user = {}) {
console.log(contact.first_name);
console.log(user.name);
let dom = `
<div class="main py-3 w-100">
<div class="container">
<div class="content">
${script}
</div>
</div>
</div>`;
console.log(dom);
//return dom;}
let script = `Hey ${contact.first_name}, ${contact.first_name} this is ${user.name} giving you a quick call from the benefits office here in ${contact.state}. I’ll have you have the phone here sec but they have me giving you a quick call because of a form you filled out requesting more information about the life insurance programs through the state of ${contact.state}. They have me, the field underwriter, calling to verify the information, I have DOB as ${contact.birthday} is that correct? Perfect, so ${contact.first_name} like I said I’m just the field underwriter they have calling to let you know your request has been processed.
We’re doing everything virtually now due to covid. Takes about 10-15 min to get you the info. Grab a pen and paper for notes and will knock this out so you don’t get any more calls.`
I want to do every variable will be replaced with function arguments
You can turn your script into a function that accepts arguments and pass it to domHTML, that way script function can get the variables of contact and user passed to it.
function domHTML(fn ,contact = {}, user = {}) {
let theScript = fn(contact, user)
let dom = `
<div class="main py-3 w-100">
<div class="container">
<div class="content">
${theScript}
</div>
</div>
</div>`;
return dom;
}
function script(contact, user){
return `Hey ${contact.first_name}, ${contact.first_name} this is ${user.name} giving you a quick call from the benefits office here in ${contact.state}.
I’ll have you have the phone here sec but they have me giving you a quick call because of a form you filled out requesting more information about the life insurance programs through the state of ${contact.state}.
They have me, the field underwriter, calling to verify the information,
I have DOB as ${contact.birthday} is that correct? Perfect,
so ${contact.first_name} like I said I’m just the field underwriter they have calling to let you know your request has been processed.`
}
const dom = domHTML(script, contact, user)
console.log(dom)