3 ms·
I think what you want is to just make a function and pass it the values: const template = ({name}) => `hello ${name}`; const n1 = template({ name: 'joe' })
by wolfgang42 1y ago
I think what you want is to just make a function and pass it the values:
const template = ({name}) => `hello ${name}`;
const n1 = template({ name: 'joe' });
(Tagged templates won’t help here because the bit in curly braces is an expression which is evaluated to a value first; you’d need some kind of macro system to get access to the original variable name at runtime.)