Here's what I'm trying to achieve.
let something = 'first string';
let template = `asdf=${something}asdf`;
some.method(template)
.then(function() {
let something = 'new string';
console.log(template);
// does not return 'asdf=new stringasdf' like expected
});
How would I keep the template, but switch out a variable inside it whenever I want (inside a scoped function)?
some.method
may or may not contain the${something}
clause. @Robin's suggestion is the correct approach, wrapping the template in a function to provide the behaviour.