thx / gogocode

GoGoCode is a transformer for JavaScript/Typescript/HTML based on AST but providing a more intuitive API.
MIT License
5.47k stars 417 forks source link

模版字符串如何用函数包裹? #243

Closed mystylemylife closed 6 months ago

mystylemylife commented 9 months ago

demo:

 const a=`${a}11${b}`

如何实现下面代码

const a=$fn(`${a}11${b}`)
shuerguo999 commented 6 months ago

const res = $('const a=${a}11${b}') .find({ type: 'TemplateLiteral'}) .each(item => { const matcher = item.generate() item.replaceBy($fn(${matcher})) }) .root() .generate()