Skip to content

Commit

Permalink
filters: simplify raw file filtering interface
Browse files Browse the repository at this point in the history
If the filter has a raw property and it evaluates to true,
pass it the input data without decoding it to text.
  • Loading branch information
matheusmoreira committed Aug 31, 2023
1 parent 8f0c811 commit 44bfbb8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ function applyFilters(ast, filters, options, filterAliases) {

function filterFile(filter, filename, file, attrs) {
let resolvedFilter = resolveFilter(filter, filters, filterAliases);
if (resolvedFilter.renderBuffer) {
return resolvedFilter.renderBuffer(file.raw, attrs);
} else {
return resolvedFilter(file.str, attrs);
}
let input = resolvedFilter.raw? file.raw : file.str;
return resolvedFilter(inout, attrs);
}
},
{includeDependencies: true}
Expand Down

0 comments on commit 44bfbb8

Please sign in to comment.