-
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
Description
Found a weird issue: if you use posthtml-expressions together with this plugin, it will fail with either a TypeError or a ReferenceError (depending on which one you add to the plugins array first).
So this setup:
const html = `<fetch url="https://jsonplaceholder.typicode.com/users/1">
{{ response.name }}
</fetch>`
posthtml([
require('posthtml-expressions')({ locals: { var: 'test' } }),
require('posthtml-fetch')()
])
.process(html)
.then(result => result.html)
.catch(error => { throw error })Fails with ReferenceError: response is not defined
If you switch plugin order, you get TypeError: nodes.reduce is not a function.
However, if you skip expression parsing with @{{ }}, it works 😵
<fetch url="https://jsonplaceholder.typicode.com/users/1">
@{{ response.name }}
</fetch>... that correctly outputs 'Leanne Graham' and the build doesn't break.
@Scrum any ideas? Is my setup wrong or is there a bug in the plugin?