Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Stripping whitespace out of your Handlebars templates

License

NotificationsYou must be signed in to change notification settings

mainmatter/ember-hbs-minifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stripping whitespace out of your Handlebars templates

Disclaimer: This is an experiment and might change in the future. Do notuse 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 above

Installation

ember install ember-hbs-minifier

Usage

ember-hbs-minifier will remove unnecessary text nodes from your templatesand collapse whitespace into single space characters. This is all doneautomatically for you (without having to use e.g.{{~foo~}}) but isdisabled for certain situations:

  • Inside of<pre></pre> 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 blockscontaining 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 defaultconfiguration in yourember-cli-build.js file:

letapp=newEmberApp({'ember-hbs-minifier':{skip:{classes:[],// skip whitespace stripping in `<pre></pre>` tagselements:['pre'],// skip whitespace stripping in `{{#no-minify}}{{/no-minify}}` blockscomponents:['no-minify'],},},});

License

ember-hbs-minifier is developed by and ©Mainmatter GmbH and contributors. It is released under theMIT License.


[8]ページ先頭

©2009-2025 Movatter.jp