diff --git a/tools/transpiler/spec/lang_spec.js b/tools/transpiler/spec/lang_spec.js new file mode 100644 index 0000000000..460d258984 --- /dev/null +++ b/tools/transpiler/spec/lang_spec.js @@ -0,0 +1,9 @@ +import {describe, it, expect} from 'test_lib/test_lib'; + +export function main() { + describe('lang', function() { + it('string interpolation', function() { + expect(`${123}-'${456}"`).toEqual('123-\'456"'); + }); + }); +} diff --git a/tools/transpiler/src/dart_writer.js b/tools/transpiler/src/dart_writer.js index d16426fa6b..9dd0f3a942 100644 --- a/tools/transpiler/src/dart_writer.js +++ b/tools/transpiler/src/dart_writer.js @@ -1,5 +1,6 @@ import {CONSTRUCTOR, FROM} from 'traceur/src/syntax/PredefinedName'; -import {EQUAL_EQUAL_EQUAL, OPEN_PAREN, CLOSE_PAREN, IMPORT, SEMI_COLON, STAR, OPEN_CURLY, CLOSE_CURLY, COMMA, AT, EQUAL} from 'traceur/src/syntax/TokenType'; +import {EQUAL_EQUAL_EQUAL, OPEN_PAREN, CLOSE_PAREN, IMPORT, SEMI_COLON, STAR, OPEN_CURLY, CLOSE_CURLY, COMMA, AT, + EQUAL, SINGLE_QUOTE} from 'traceur/src/syntax/TokenType'; import {ParseTreeWriter as JavaScriptParseTreeWriter} from 'traceur/src/outputgeneration/ParseTreeWriter'; @@ -37,6 +38,17 @@ export class DartTreeWriter extends JavaScriptParseTreeWriter { } } + visitTemplateLiteralExpression(tree) { + if (tree.operand) { + this.visitAny(tree.operand); + this.writeSpace_(); + } + this.writeRaw_(SINGLE_QUOTE); + this.visitList(tree.elements); + this.writeRaw_(SINGLE_QUOTE); + } + + // FUNCTIONS // - remove the "function" keyword // - type annotation infront