Skip to content

Using tagged template literals, revisted

I thought I had a clever way of using tagged template literals with Array.prototype.reduce, but it turns out that String.raw does this already.

So my template function should be:

function template(strings, ...keys) {
  return (data) => String.raw( {raw: strings, (key => data[key]) );

Which is much simpler

Post a Comment

Your email is never published nor shared. Required fields are marked *