-
Notifications
You must be signed in to change notification settings - Fork 16
📬 Feature: post processors #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jimlambie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
|
This is a breaking change because it removes |
|
Yes exactly, that setting will no longer have any effect...not sure how to handle it since it was undocumented anyway? You could only turn it on page-by-page in the AFAIK we're not using it in any client work either. |
|
Perhaps we should make some enquiries then - if it's not used we can simply make it a new feature and release as a minor version |
|
Added upgrade notes from |
eduardoboucas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool! Just added some minor comments.
dadi/lib/view/index.js
Outdated
| .then(output => { | ||
| let err = null | ||
| // Send the templated page | ||
| let templateData = Object.assign(this.data, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, to avoid mutating this.data, you could do Object.assign({}, this.data, (...)).
dadi/lib/view/index.js
Outdated
|
|
||
| // Post-process the output | ||
| if (config.get('globalPostProcessors') || this.page.postProcessors) { | ||
| let postProcessors = config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a const?
dadi/lib/view/index.js
Outdated
| keepWhitespace: this.page.keepWhitespace | ||
| }) | ||
| .then(output => { | ||
| let err = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable doesn't seem to ever be changed. You're returning an error on L60 but it comes from L59. Could we remove this initialisation and just do return done(null, output) on L65?
|
Great suggestions, thanks @eduardoboucas! |
|
This still has to be a major release, right? If we're not bundling in a beautify processor and honouring the existing page setting for beautify, then it's a breaking change. This would make it Web 5.0. |
|
Yep makes sense 👍 |
|
Agree 💯 %. |
|
I'm a bit wary of another major release so soon after 4.0, is all. Feels like we're following the FB Messenger app approach - they're up to version 133 or something. Mind you, their release notes are awful. "Performance enhancements". |
|
That's understandable. If this is not an urgent requirement, perhaps we can hit pause and bundle it with other breaking changes for the next major release? ⏸ |
|
Could we prepare a 5.0 branch perhaps? Just conscience that this branch will get stale and drift from head. |
|
Good idea. We could start a |
Removes the previously undocumented
page.settings.beautifyoption & closes #154 (related to #162).Adds the ability to manipulate the raw output of the template engine, before the page is cached and served. Similar to the Wordpress feature, it is useful for linting (thinking RSS feeds in particular), minifying and formatting. They are loaded in order of definition, global first, and the output is passed from one to the next so you can chain functions.
Example usage: minifying HTML.
config.json
/workspace/processors/minify-html.js(using html-minifier)Note:
page.settingsAdd a processor, in addition to the global
Disable for given page
Upgrading from
page.settings.beautifyInstall package
New file
workspace/processors/beautify-html.jsOld
page.json{ "page": { "name": "Sitemap page", "description": "Sitemap", "language": "en" }, "settings": { "cache": true, "beautify": true }, ... }New
page.json{ "page": { "name": "Sitemap page", "description": "Sitemap", "language": "en" }, "settings": { "cache": true, "postProcessors": [ "beautify-html" ] }, ... }