Merge pull request #480 from monsanto/loose-templates
Add loose transform for tagged template literals
This commit is contained in:
commit
fe6f53d471
@ -24,6 +24,7 @@ File.helpers = [
|
||||
"prototype-properties",
|
||||
"apply-constructor",
|
||||
"tagged-template-literal",
|
||||
"tagged-template-literal-loose",
|
||||
"interop-require",
|
||||
"to-array",
|
||||
"sliced-to-array",
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
(function (strings, raw) {
|
||||
strings.raw = raw;
|
||||
return strings;
|
||||
});
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user