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-loader-ignore-helpers

v1.5.0

Published

handlebars loader module for webpack

Downloads

2

Readme

handlebars-loader-ignore-helpers

Forked just for include PR 136.

A handlebars template loader for webpack.

Handlebars 4 now supported

Installation

npm i handlebars-loader-ignore-helpers --save

General Usage

webpack configuration

{
  ...
  module: {
    rules: [
      ...
      { test: /\.handlebars$/, loader: "handlebars-loader" }
    ]
  }
}

Your JS making use of the templates

var template = require("./file.handlebars");
// => returns file.handlebars content as a template function

Details

The loader resolves partials and helpers automatically. They are looked up relative to the current directory (this can be modified with the rootRelative option) or as a module if you prefix with $.

A file "/folder/file.handlebars".
{{> partial}} will reference "/folder/partial.handlebars".
{{> ../partial}} will reference "/partial.handlebars".
{{> $module/partial}} will reference "/folder/node_modules/module/partial.handlebars".
{{helper}} will reference the helper "/folder/helper.js" if this file exists.
{{[nested/helper] 'helper parameter'}} will reference the helper "/folder/nested/helper.js" if this file exists, passes 'helper parameter' as first parameter to helper.
{{../helper}} {{$module/helper}} are resolved similarly to partials.

The following query (or config) options are supported:

  • helperDirs: Defines additional directories to be searched for helpers. Allows helpers to be defined in a directory and used globally without relative paths. You must surround helpers in subdirectories with brackets (Handlerbar helper identifiers can't have forward slashes without this). See example
  • runtime: Specify the path to the handlebars runtime library. Defaults to look under the local handlebars npm module, i.e. handlebars/runtime.
  • extensions: Searches for templates with alternate extensions. Defaults are .handlebars, .hbs, and '' (no extension).
  • inlineRequires: Defines a regex that identifies strings within helper/partial parameters that should be replaced by inline require statements.
  • rootRelative: When automatically resolving partials and helpers, use an implied root path if none is present. Default = ./. Setting this to be empty effectively turns off automatically resolving relative handlebars resources for items like {{helper}}. {{./helper}} will still resolve as expected.
  • knownHelpers: Array of helpers that are registered at runtime and should not explicitly be required by webpack. This helps with interoperability for libraries like Thorax helpers.
  • exclude: Defines a regex that will exclude paths from resolving. This can be used to prevent helpers from being resolved to modules in the node_modules directory.
  • debug: Shows trace information to help debug issues (e.g. resolution of helpers).
  • partialDirs: Defines additional directories to be searched for partials. Allows partials to be defined in a directory and used globally without relative paths. See example
  • preventIndent: Prevent partials from being indented inside their parent template.
  • ignorePartials: Prevents partial references from being fetched and bundled. Useful for manually loading partials at runtime.
  • ignoreHelpers: Prevents helper references from being fetched and bundled. Useful for manually loading helpers at runtime.
  • compat: Enables recursive field lookup for Mustache compatibility. See the Handlebars.js documentation for more information.
  • config: Tells the loader where to look in the webpack config for configurations for this loader. Defaults to handlebarsLoader.
  • config.partialResolver You can specify a function to use for resolving partials. To do so, add to your webpack config:
    handlebarsLoader: {
        partialResolver: function(partial, callback){
            // should pass the partial's path on disk
            // to the callback. Callback accepts (err, locationOnDisk)
        }
    }
  • config.helperResolver You can specify a function to use for resolving helpers. To do so, add to your webpack config:
    handlebarsLoader: {
        helperResolver: function(helper, callback){
            // should pass the helper's path on disk
            // to the callback if one was found for the given parameter.
            // Callback accepts (err, locationOnDisk)
            // Otherwise just call the callback without any arguments
        }
    }

See webpack documentation for more information regarding loaders.

Full examples

See the examples folder in this repo. The examples are fully runnable and demonstrate a number of concepts (using partials and helpers) -- just run webpack in that directory to produce dist/bundle.js in the same folder, open index.html.

Change Log

See the CHANGELOG.md file.

License

MIT (http://www.opensource.org/licenses/mit-license)