Multiline template strings that don't break indentation

Sebastian Zartner sebastianzartner at gmail.com
Wed Sep 10 22:55:45 PDT 2014


On 9 September 2014 16:51, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:

> Well, just for fun
>
>         const N = "\n";  //maybe we could find evocative unicode name.
>         var a = `This is a template string. ${
>                N}Even though each line is indented to keep the ${
>                N}code neat and tidy, the white space used to indent ${
>                N}is not in the resulting string`;
>

To me this looks still somewhat hacky.
Couldn't a simple keyword be added at the the end of a template string?
So it would be something like this:

        var a = `This is a template string.
                 Even though each line is indented to keep the
                 code neat and tidy, the white space used to indent
                 is not in the resulting string` keepindentation;

This would explicitly keep the spaces at the beginning of each line while
without the keyword they would be removed. Of course the keyword may also
indicate the opposite depending on parsing would be chosen as default.
Surely the name for this keyword is not optimal yet and would need to be
discussed.

Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140911/a46b40c7/attachment.html>


More information about the es-discuss mailing list