Discussion:
Multiline template strings that don't break indentation
Owen Densmore
2014-09-18 02:44:14 UTC
Permalink
I'm always surprised we keep forgetting coffeescrip,
http://coffeescript.org/t:

Multiline strings are allowed in CoffeeScript.
Lines are joined by a single space unless they end with a backslash.
Indentation is ignored.

mobyDick = "Call me Ishmael. Some years ago -- never mind how long
precisely -- having little or no money in my purse, and nothing particular
to interest me on shore, I thought I would sail about a little and see the
watery part of the world..."


and:

Block strings can be used to hold formatted or indentation-sensitive
text
(or, if you just don't feel like escaping quotes and apostrophes).
The indentation level that begins the block is maintained throughout,
so you can keep it all aligned with the body of your code.

html = """ <strong> cup of coffeescript </strong> """


-- Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140917/32524a3e/attachment.html>
Merih
2014-09-18 23:35:50 UTC
Permalink
This might be beyond the current state of template strings but wouldn't it
be nice if there was a delimiter character we can use to depict the
beginning of each line of a multiline string? A similar solution like Scala
multliline strings but without `stripMargin` method at the end.

For example:

var multiLineString = `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 we actually want to include vertical bar we can escape it?

--
Merih Akar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140919/bf294573/attachment.html>
Domenic Denicola
2014-09-18 23:52:57 UTC
Permalink
ALL of these things can be accomplished with your own custom tag. I really encourage you and others to learn about the "tag" part of "tagged template string".
________________________________
From: Merih<mailto:merihakar at gmail.com>
Sent: ?2014-?09-?18 16:36
To: es-discuss at mozilla.org<mailto:es-discuss at mozilla.org>
Subject: Re: Re: Multiline template strings that don't break indentation

This might be beyond the current state of template strings but wouldn't it be nice if there was a delimiter character we can use to depict the beginning of each line of a multiline string? A similar solution like Scala multliline strings but without `stripMargin` method at the end.

For example:

var multiLineString = `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 we actually want to include vertical bar we can escape it?

--
Merih Akar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140918/520b13f9/attachment.html>
Alexander Kit
2014-10-13 16:27:30 UTC
Permalink
On 19 September 2014 01:52, Domenic Denicola <domenic at domenicdenicola.com>
Post by Domenic Denicola
ALL of these things can be accomplished with your own custom tag.
Yes, it can be accomplished with the custom tag function. But this is not
the argument, as also a lot of other things from ES6 spec can be
accomplished with some **custom** libraries (see all the shims), but we
anyway have them in es6. And so, I would also like to see here the spec.
regarding the indentation. (*prefer native to custom)*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141013/cfe43f90/attachment.html>
Brendan Eich
2014-10-13 19:29:25 UTC
Permalink
Post by Alexander Kit
On 19 September 2014 01:52, Domenic Denicola
ALL of these things can be accomplished with your own custom tag.
Yes, it can be accomplished with the custom tag function. But this is
not the argument, as also a lot of other things from ES6 spec can be
accomplished with some **custom** libraries (see all the shims), but
we anyway have them in es6. And so, I would also like to see here the
spec. regarding the indentation. (/prefer native to custom)/
"Custom" means prototype it first, as ksmith said: "in userland". Do
that, even now using Traceur, and then let's talk about a built-in.

/be

Loading...