Merge pull request #2790 from moretti/issue-2613

Preserve indentation in template literals, fixes #2613
This commit is contained in:
Sebastian McKenzie 2015-11-03 20:13:09 +00:00
commit 9eee677321
3 changed files with 34 additions and 1 deletions

View File

@ -18,7 +18,7 @@ export function TemplateLiteral(node: Object) {
this.print(quasis[i], node);
if (i + 1 < quasis.length) {
this.push("${ ");
this._push("${ ");
this.print(node.expressions[i], node);
this.push(" }");
}

View File

@ -0,0 +1,18 @@
function multilineTemplate() {
return `I'm done reconfoobling
${ 'the energy motron' }
${'...or whatever'}`;
}
{
const foo = `spam
and eggs!`;
const bar = `${
4 +
2
}`;
const hello = `Hello
${ 'world' }`;
}

View File

@ -0,0 +1,15 @@
function multilineTemplate() {
return `I'm done reconfoobling
${ 'the energy motron' }
${ '...or whatever' }`;
}
{
const foo = `spam
and eggs!`;
const bar = `${ 4 + 2 }`;
const hello = `Hello
${ 'world' }`;
}