Created
September 11, 2019 09:51
-
-
Save bwindels/46d69efde2963c13f2d7bf07626ede1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const acorn = require("acorn"); | |
const walk = require("acorn-walk"); | |
walk.simple(acorn.parse("import i18n from \"i18n\"; const str = i18n`foo ${bar} haha`", {sourceType: "module"}), { | |
// https://github.com/estree/estree/blob/master/es2015.md#template-literals | |
TaggedTemplateExpression(node) { | |
console.log("TaggedTemplateExpression:") | |
console.log(JSON.stringify(node, undefined, 2)); | |
}, | |
ImportDeclaration(node) { | |
console.log("ImportDeclaration:") | |
console.log(JSON.stringify(node, undefined, 2)); | |
} | |
}); |
e.g. support
const str = this.i18n`foo ${bar} haha`;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could also use a local variable for the tag instead of a global imported variable