Multiline template strings that don't break indentation

Andy Earnshaw andyearnshaw at
Tue Sep 9 16:01:22 PDT 2014

Allen's is pretty clever and I'd be almost tempted to use it ;-)

On Tue, Sep 9, 2014 at 4:44 PM, Kevin Smith <zenparsing at> wrote:

> You can create a really flexible "dedent" function/tag pretty easily:
> Nice, right?

I wrote a function-as-a-tag that "dedented" (since that's the word we're
all using) when I was playing around too.  It's *really nice*.

On Tue, Sep 9, 2014 at 5:26 PM, Alexander Kit <alex.kit at> wrote:

I would also hope that the trailing indentions will be cut off from the
> template string. We had the case in our template engine, multiline strings
> are supported and it behaives as follows:
> - first line: contains a non-whitespace character → take the complete
> string as is and exit, otherwise:
> - secondline - lastline → get the smallest indention
> - secondline - lastline → trim the indention
> - last line: contains only whitespaces → remove the line
> This should cover all the cases, or do somebody has other ideas?

Git and linting tools usually bark at you if you have trailing white space
anyway, if you don't have your editor automatically removing it.  That
aside, are you suggesting that a template string like this:

    var a = `
            This has
            no indentation

should have the indentation removed, but not in the case where a non-white
space character is between the first ` and the newline?  Wouldn't that be a
tad confusing?  Also, it's common in console applications to have a
trailing newline (although you could just concat one of course).  Taking
the smallest amount of indentation away from each line is interesting,
though, and probably less confusing than my suggestion of removing white
space up to the column of the first `.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list