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",
|
"prototype-properties",
|
||||||
"apply-constructor",
|
"apply-constructor",
|
||||||
"tagged-template-literal",
|
"tagged-template-literal",
|
||||||
|
"tagged-template-literal-loose",
|
||||||
"interop-require",
|
"interop-require",
|
||||||
"to-array",
|
"to-array",
|
||||||
"sliced-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));
|
raw.push(t.literal(elem.value.raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push(t.callExpression(file.addHelper("tagged-template-literal"), [
|
strings = t.arrayExpression(strings);
|
||||||
t.arrayExpression(strings),
|
raw = t.arrayExpression(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);
|
args = args.concat(quasi.expressions);
|
||||||
|
|
||||||
return t.callExpression(node.tag, args);
|
return t.callExpression(node.tag, args);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user