Multiline template strings that don't break indentation

Sebastian Zartner sebastianzartner at gmail.com
Thu Sep 11 22:40:24 PDT 2014


>
> The tag goes at the front.
>
> I know. I didn't see this functionality as a tag, though, but rather as a
flag for the client. Having this functionality available as a tag has some
consequences. See below.

> What's missing from the design that can't be provided as a standard
> exported deindent function?
>
> Concatenating tags, maybe? And the function itself?

> exactly:
>
>         var a = dontIndent
>                 `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`;
>
> or, following the precedent to 'raw':
>
>         var a = String.noIndentation
>                 `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`;
>

And if someone wants to use his own tag? Would he have to reimplement
dontIndent or String.noIndentation by himself?

What I meant above with tag concatenation would be something like this:

        var a = String.noIndentation myTag
                `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`;

So first the template string would be parsed by String.noIndentation and
subsequently by myTag.

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


More information about the es-discuss mailing list