Template strings flags

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Template strings flags

Alexander Guinness
Why not provide special formatting flags for `Template strings`? ```js let text = `text text text text text text text text text text text text`t; ``` `t` - trim whitespaces Expected result: ```js let text = `text text text text text text text text text text text text`t; ```


-----------------------------------------
Alexander

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Template strings flags

Axel Rauschmayer
Alternative: an operator for function composition.

```js
let text = `…` @@ t;
```


On 17 Apr 2015, at 19:13, monolithed <[hidden email]> wrote:

Why not provide special formatting flags for `Template strings`? ```js let text = `text text text text text text text text text text text text`t; ``` `t` - trim whitespaces Expected result: ```js let text = `text text text text text text text text text text text text`t; ```

-- 
Dr. Axel Rauschmayer
[hidden email]
rauschma.de




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Template strings flags

Kevin Smith
In reply to this post by Alexander Guinness

Why not provide special formatting flags for `Template strings`?
 
Tagged template strings are your friend.


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Template strings flags

Axel Rauschmayer
Why not provide special formatting flags for `Template strings`?
 
Tagged template strings are your friend.

If you want to modify behavior (e.g. cut off prefixed whitespace) then more trickery is needed, e.g.:

```js
dedent(String.raw)`…`
```

And there is no handler function that provides untagged behavior.

-- 
Dr. Axel Rauschmayer
[hidden email]
rauschma.de




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss