npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

handlebars-helper-minify

v0.1.3

Published

{{minify}} handlebars helper, for minification of HTML with html-minifier.

Downloads

49

Readme

{{minify}} NPM version

{{minify}} handlebars helper, for minification of HTML with html-minifier.

This helper depends on and extends js-beautify. Please visit and star that project to show your support.

Quickstart

In the root of your project, run the following in the command line:

npm i handlebars-helper-minify --save-dev

Options

All options from js-beautify are available in this helper, as well as a few custom options that were specially created for this helper. The helper comes with some sensible defaults (in the humble opinion of the helper creator), but it's easy to customize them if you need to. Here are are two (convenient) ways to set options:

  • options object: pass an options object to the helper as a parameter. E.g. {{#minify opts.obj}}.
  • options hash: this is an easy way to set options on the helper, and it also gives you granular control over how the helper renders content.
  • Gruntfile: if you use both Grunt and Assemble, you can define options in the Assemble task options of your project's Gruntfile.

options hash

By design, options define here will override options defined anywhere else. This approach also provides granular control over options, allowing you to defined different options on multiple instances of the helper in the same file.

Example:

{{#minify removeComments="true"}}
  {{> header }}
{{/minify}}
{{#minify removeEmptyElements="true"}}
  {{> body }}
{{/minify}}
{{#minify removeComments="true"}}
  {{> footer }}
{{/minify}}

"assemble" task options

The helper can be used without Grunt or Assemble. But if you happen to use these two awesome tools you can define options for the helper in your Gruntfile in the minify sub-options for Assemble:

grunt.initConfig({
  assemble: {
    options: {
      minify: {
        removeAttributeQuotes: false
      }
    },
    files: {}
  }
});

Options defined in the Assemble task can be viewed as custom "global" defaults, which can be overridden by options defined in the options hash.

option defaults

{
  collapseBooleanAttributes: false,
  collapseWhitespace: true,
  removeAttributeQuotes: false,
  removeCDATASectionsFromCDATA: false,
  removeComments: false,
  removeCommentsFromCDATA: false,
  removeEmptyAttributes: false,
  removeEmptyElements: false,
  removeOptionalTags: false,
  removeRedundantAttributes: false,
  useShortDoctype: false
}

Example

Before

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>

    <!-- code comment -->
    <h1>My Blog</h1>
    <h2>Post of the day</h2>

    <!-- scripts -->
    <a href="#">Read more...</a>
  </body>
</html>

After

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title></title></head><body><!-- code comment --><h1>My Blog</h1><h2>Post of the day</h2><!-- scripts --><a href="#">Read more...</a></body></html>

Contributing

Please see the Contributing to Assemble guide for information on contributing to this project.

Author

Jon Schlinkert

Related Projects and Links

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license


This file was generated on March 10, 2014.