I'm trying to query the following:
const t = 'template';
const s = `I'm a ${t}`;
Acorn parses the template literal portion as:
{
"type": "TemplateLiteral",
"start": 32,
"end": 53,
"expressions": [
{
"type": "Identifier",
"start": 50,
"end": 51,
"name": "t"
}
],
"quasis": [
{
"type": "TemplateElement",
"start": 33,
"end": 48,
"value": {
"raw": "I'm a ",
"cooked": "I'm a "
},
"tail": false
},
{
"type": "TemplateElement",
"start": 52,
"end": 52,
"value": {
"raw": "",
"cooked": ""
},
"tail": true
}
]
}
Let's say I wanted to query this by the raw
or cooked
keys of the value
key of the TemplateElement
. Since the nested value
item doesn't have a type I'm a bit lost as to how to target that node by those attributes. How would I write that query using astq?