Multiline template strings that don't break indentation

李白|字一日 calidion at gmail.com
Wed Sep 10 23:36:42 PDT 2014


I would prefer

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`;

as a multiple line string,


2014-09-11 13:55 GMT+08:00 Sebastian Zartner <sebastianzartner at gmail.com>:

> 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
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140911/f5dfc5b4/attachment.html>


More information about the es-discuss mailing list