From 93f6d26f688749180c83fb268bc9ac03b4d2e43f Mon Sep 17 00:00:00 2001 From: Tommy Odom Date: Sun, 9 Nov 2014 10:06:20 -0500 Subject: [PATCH] feat(transpiler): Transform template strings to triple quoted Dart strings --- tools/transpiler/spec/lang_spec.js | 5 +++++ .../transpiler/src/outputgeneration/DartParseTreeWriter.js | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/transpiler/spec/lang_spec.js b/tools/transpiler/spec/lang_spec.js index 460d258984..dabfc535e5 100644 --- a/tools/transpiler/spec/lang_spec.js +++ b/tools/transpiler/spec/lang_spec.js @@ -5,5 +5,10 @@ export function main() { it('string interpolation', function() { expect(`${123}-'${456}"`).toEqual('123-\'456"'); }); + + it('multiline string', function () { + expect(`1' +2"`).toEqual('1\'\n2"'); + }); }); } diff --git a/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js b/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js index cad44e4013..908f1473b6 100644 --- a/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js +++ b/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js @@ -75,12 +75,11 @@ export class DartParseTreeWriter extends JavaScriptParseTreeWriter { visitTemplateLiteralExpression(tree) { if (tree.operand) { - this.visitAny(tree.operand); - this.writeSpace_(); + throw new Error('tagged template strings are not supported'); } - this.writeRaw_('"'); + this.writeRaw_("'''"); this.visitList(tree.elements); - this.writeRaw_('"'); + this.writeRaw_("'''"); } visitTemplateLiteralPortion(tree) {