diff --git a/packages/babel-generator/src/generators/template-literals.js b/packages/babel-generator/src/generators/template-literals.js index ed644eedb0..6b815a0a57 100644 --- a/packages/babel-generator/src/generators/template-literals.js +++ b/packages/babel-generator/src/generators/template-literals.js @@ -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(" }"); } diff --git a/packages/babel-generator/test/fixtures/harmony-edgecase/templates-indentation/actual.js b/packages/babel-generator/test/fixtures/harmony-edgecase/templates-indentation/actual.js new file mode 100644 index 0000000000..a4c21377e2 --- /dev/null +++ b/packages/babel-generator/test/fixtures/harmony-edgecase/templates-indentation/actual.js @@ -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' }`; +} diff --git a/packages/babel-generator/test/fixtures/harmony-edgecase/templates-indentation/expected.js b/packages/babel-generator/test/fixtures/harmony-edgecase/templates-indentation/expected.js new file mode 100644 index 0000000000..1f664f0ae2 --- /dev/null +++ b/packages/babel-generator/test/fixtures/harmony-edgecase/templates-indentation/expected.js @@ -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' }`; +}