Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mainmatter/ember-hbs-minifier
Stripping whitespace out of your Handlebars templates
https://github.com/mainmatter/ember-hbs-minifier
Last synced: about 2 months ago
JSON representation
Stripping whitespace out of your Handlebars templates
- Host: GitHub
- URL: https://github.com/mainmatter/ember-hbs-minifier
- Owner: mainmatter
- License: mit
- Created: 2017-01-11T21:57:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T03:33:24.000Z (8 months ago)
- Last Synced: 2024-05-21T04:37:59.808Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.73 MB
- Stars: 48
- Watchers: 7
- Forks: 10
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-ember - ember-hbs-minifier - Stripping whitespace out of your Handlebars templates. (Packages / Minifiers)
README
ember-hbs-minifier
==============================================================================Stripping whitespace out of your Handlebars templates
__Disclaimer:__ This is an experiment and might change in the future. Do not
use this for production yet unless you understand the consequences!Compatibility
------------------------------------------------------------------------------* Ember.js v3.20 or above
* Ember CLI v3.20 or above
* Node.js 12 or aboveInstallation
------------------------------------------------------------------------------```
ember install ember-hbs-minifier
```Usage
------------------------------------------------------------------------------`ember-hbs-minifier` will remove unnecessary text nodes from your templates
and collapse whitespace into single space characters. This is all done
automatically for you (without having to use e.g. `{{~foo~}}`) but is
disabled for certain situations:- Inside of `
` tags- Inside of `{{#no-minify}}{{/no-minify}}` blocks
(these will be stripped from the template)Please note that this does not work across component/template boundaries.
What happens in particular is:
- Text nodes containing only whitespace are collapsed to `' '`
(a single space character)- Leading or trailing text nodes inside of tags or handlebars blocks
containing only whitespace are removed entirely### Configuration
If you want to disable the whitespace stripping behavior for other tags,
components, or elements with certain CSS classes you can adjust the default
configuration in your `ember-cli-build.js` file:```javascript
` tags
let app = new EmberApp({
'ember-hbs-minifier': {
skip: {
classes: [],
// skip whitespace stripping in `
elements: ['pre'],
// skip whitespace stripping in `{{#no-minify}}{{/no-minify}}` blocks
components: ['no-minify'],
},
},
});
```License
------------------------------------------------------------------------------ember-hbs-minifier is developed by and ©
[Mainmatter GmbH](http://mainmatter.com) and contributors. It is released under the
[MIT License](LICENSE.md).