support tagged template literals - closes #16
This commit is contained in:
parent
21f039e775
commit
b59168832c
@ -5,6 +5,22 @@ var buildBinaryExpression = function (left, right) {
|
||||
return b.binaryExpression("+", left, right);
|
||||
};
|
||||
|
||||
exports.TaggedTemplateExpression = function (node) {
|
||||
var args = [];
|
||||
var quasi = node.quasi;
|
||||
|
||||
var strings = quasi.quasis.map(function (elem) {
|
||||
return b.literal(elem.value.raw);
|
||||
});
|
||||
args.push(b.arrayExpression(strings));
|
||||
|
||||
_.each(quasi.expressions, function (expr) {
|
||||
args.push(expr);
|
||||
});
|
||||
|
||||
return b.callExpression(node.tag, args);
|
||||
};
|
||||
|
||||
exports.TemplateLiteral = function (node) {
|
||||
var nodes = [];
|
||||
|
||||
|
||||
1
test/fixtures/template-literals/tag/actual.js
vendored
Normal file
1
test/fixtures/template-literals/tag/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = bar`a${ 42 }b ${_.foobar()}`;
|
||||
1
test/fixtures/template-literals/tag/expected.js
vendored
Normal file
1
test/fixtures/template-literals/tag/expected.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var foo = bar(["a", "b ", ""], 42, _.foobar());
|
||||
Loading…
x
Reference in New Issue
Block a user