0

What is the best way to use ES2015 string templates from another file?

template.html

<div>
    <span>Hello, my name is ${name}.</span>
    <span>I'm a ${title}.</span>
</div>

main.js

let template = '';
let name = "Adam Curl"
let title = "Coder"
$.get("template.html", function(response) {
     template = response;
});
console.log(template);

Wishing to output...

<div>
    <span>Hello, my name is Adam Curl.</span>
    <span>I'm a Coder.</span>
</div>
guest271314
  • 1
  • 15
  • 104
  • 177
Chance Smith
  • 1,211
  • 1
  • 15
  • 32

0 Answers0