Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #52 from timswalling/feature/beautify-options
Browse files Browse the repository at this point in the history
Add user-configurable `beautify` filter
  • Loading branch information
dkhuntrods authored Aug 2, 2017
2 parents 4785b11 + b995841 commit c5de4d7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@ module.exports = function(theme, env, app){
});

env.engine.addFilter('beautify', function(str) {
return beautifyHTML(str, {
// TODO: move to config
indent_size: 4,
preserve_newlines: true,
max_preserve_newlines: 1
});
const defaults = {
indent_size: 4,
preserve_newlines: true,
max_preserve_newlines: 1
};

let beautifyOptions = theme.getOption('beautify') || {};

if (typeof beautifyOptions === 'function') {
return beautifyOptions(str);
}

beautifyOptions = _.merge({}, defaults, beautifyOptions);

return beautifyHTML(str, beautifyOptions);
});

env.engine.addFilter('resourceUrl', function(str) {
Expand Down

0 comments on commit c5de4d7

Please sign in to comment.