Closed zmanring-zz closed 7 years ago
Yeah I got the filters working in Pug
but not through through the grunt system.
Are you using the same version? Currently this plugin depends on this version: https://github.com/gruntjs/grunt-contrib-pug/blob/563653da682115af43767aa8d1d90343daab9d70/package.json#L20
I was on alpha7 and I reverted, same issue.
Example use:
options: {
data: {
dist: true
},
filters: {
renderComponent: function(block) {
return block;
},
content: function(block) {
return block;
}
}
For anyone else who may run into this issue, I fixed it by adding an empty data object to the options. If you look at tasks/pug.js#L69 you can see that f.orig.data
can end up being undefined if options.data
is not specified, so the check for filters on tasks/pug.js#L72 will throw the error.
Maybe the code could be updated to f.orig.data = data || {};
.
As a side note, if you are require()
ing the filters then you'll have to manually restart the grunt process instead of relying on grunt watch
, since the require()
calls are cached and grunt watch
does not invalidate this cache.
I have a filter under the options object but when I build it gives me an error.