String identity template tag
T.J. Crowder
tj.crowder at farsightsoftware.com
Thu Dec 13 18:44:29 UTC 2018
On Thu, Dec 13, 2018 at 6:37 PM T.J. Crowder
<tj.crowder at farsightsoftware.com> wrote:
>
> But called normally, it's a useful helper, for instance in
> Isiah's `escape`...
Going through the process of the example for my message just now made me
think more about this function. Suppose it:
1. Accepted an array of substitutions rather than a rest parameter, and
2. Accepted an optional mapping function
Then, what I wrote on my last message as:
```js
const escape = (strings, ...subs) => {
return String.cook(strings, ...subs.map(escapeHTML));
};
```
would be
```js
const escape = (strings, ...subs) => *String.cook(strings, subs,
escapeHTML)*;
```
(http://jsfiddle.net/n6p7xcvm/1/)
...while still supporting the earlier usage (just without spread) if
desired.
-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20181213/c8032178/attachment.html>
More information about the es-discuss
mailing list