Registry / devops / handlebars-helper-minify

handlebars-helper-minify

JSON →
library0.1.3jsnpmunverified

A Handlebars helper for minifying HTML using html-minifier. Version 0.1.3 is the latest stable release. This is an older package (last updated ~2014) with no active development. It depends on and extends js-beautify. Options can be set via hash parameters, an options object, or Gruntfile Assemble task config. This package is part of the 'helpers' collection which provides alternative, more specific helpers not included in the main handlebars-helpers project.

npm install handlebars-helper-minify
INSTALL
IMPORT
SIG · HANDLEBARS-HELPER-
H
handlebars-helper-minify
devopsjavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

helpertest
const handlebars = require('handlebars'); handlebars.registerHelper('minify', require('handlebars-helper-minify'));
import { minify } from 'handlebars-helper-minify'
This is a CommonJS package that exports a function to be registered as a Handlebars helper. No default export.
minify
hbs.registerHelper('minify', require('handlebars-helper-minify'));
hbs.registerHelper('minify', require('handlebars-helper-minify').minify);
The module exports the helper function directly, not as a property.
helper
const helper = require('handlebars-helper-minify'); helper(hbs); // if used with a framework that auto-registers
Some frameworks expect a function that registers itself. Check the framework's documentation.

Registers the minify helper and uses it to minify a partial's content.

const Handlebars = require('handlebars'); const minifyHelper = require('handlebars-helper-minify'); Handlebars.registerHelper('minify', minifyHelper); const template = Handlebars.compile('{{#minify collapseWhitespace="true"}}{{> content}}{{/minify}}'); Handlebars.registerPartial('content', '<p> Hello World </p>'); console.log(template()); // "<p> Hello World </p>"
Debug
Known issues
deprecatedPackage is outdated and no longer maintained. Use modern alternatives like html-minifier-terser directly via a helper or transform.
fix
Use a more modern Handlebars helper or inline html-minifier logic.
affects: all
gotchaThe helper uses html-minifier but options are documented as js-beautify options, which may be confusing. Not all js-beautify options are supported.
fix
Refer to html-minifier documentation for actual options.
affects: all
breakingWorks only with Handlebars v3-4. Incompatible with Handlebars v5+ due to API changes.
fix
Use a helper compatible with your Handlebars version or inline the minification.
affects: >=0.1.0
Errors
Common errors & fixes
Debug: internal, implementation, error Minify helper is not a function
Improper registration: trying to call the helper function directly instead of registering it.
fix
Use Handlebars.registerHelper('minify', require('handlebars-helper-minify'));
TypeError: handlebars.registerHelper is not a function
Handlebars is not properly required or is undefined.
fix
Ensure Handlebars is required: const Handlebars = require('handlebars');
Warning: .isFunc is not a function
Outdated version of handlebars-helper-minify incompatible with newer Handlebars.
fix
Downgrade Handlebars to v4.x or use a different minify helper.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
handlebarsrequiredRequires Handlebars as a peer dependency for the helper to register
html-minifierrequiredUsed internally for minification
Agent activity
6 hits · last 30 days
node
6
Resources
handlebars-helper-minify — npm install handlebars-helper-minify · libregistry