add loose transform for tagged template literals

This commit is contained in:
Christopher Monsanto
2015-01-13 14:48:31 -05:00
parent afd3af834d
commit 4fdcf685d3
3 changed files with 12 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ File.helpers = [
"prototype-properties",
"apply-constructor",
"tagged-template-literal",
"tagged-template-literal-loose",
"interop-require",
"to-array",
"sliced-to-array",

View File

@@ -0,0 +1,4 @@
(function (strings, raw) {
strings.raw = raw;
return strings;
});

View File

@@ -17,11 +17,14 @@ exports.TaggedTemplateExpression = function (node, parent, file) {
raw.push(t.literal(elem.value.raw));
}
args.push(t.callExpression(file.addHelper("tagged-template-literal"), [
t.arrayExpression(strings),
t.arrayExpression(raw)
]));
strings = t.arrayExpression(strings);
raw = t.arrayExpression(raw);
var template = file.isLoose("templateLiterals") ?
"tagged-template-literal-loose" :
"tagged-template-literal";
args.push(t.callExpression(file.addHelper(template), [strings, raw]));
args = args.concat(quasi.expressions);
return t.callExpression(node.tag, args);