2 ms·
How come you haven't used tagged template literals? These would fit this use case: https://codeburst.io/javascript-es6-tagged-template-literals-a45c26e54761 htt
by baxuz 7y ago
How come you haven't used tagged template literals? These would fit this use case:
https://codeburst.io/javascript-es6-tagged-template-literals-a45c26e54761 https://codeburst.io/javascript-es6-tagged-template-literals...
- arexxbifs 7y agoIt's not my code :) However, tagged template literals won't allow dict expansion the way this solution does. Also, a template literal is evaluated at the time of assignment. This will allow you to re-use an arbitrary template string with any matching values: tpl = applyTemplate("Hello ${a}"); tpl({"a": "you"}); // --> Hello you tpl({"a": "dude"}); // --> Hello dude