Search code examples
javascripthtmlwebpackhandlebars.js

Webpack, figuring out where to register Handlebar helpers to my project


I have an annoying problem which is bothering me because I'm not used to work with Handlebars templating system.

I forked a project off git (https://github.com/SimonDEvans/design-boilerplate) which included basic Handlebars integration. In the README it states that the project support Handlebars helpers.

However the documentation is lacking and I can't find WHERE I even put Handlebar helper functions in so that I can use them in my templating files.

So I turn to SO to see if any of you guys have worked with similar setups using the handlebars-loader NPM

Here is a snippet of the Webpack config file that runs the handlebars node

function getLoaders() {
  const loaders = [
    {
      test: /\.html$/,
      loader: 'handlebars-loader',
    },
    {
      test: /\.js$/,
      include: [
        path.join(__dirname, 'src'),
        path.join(__dirname, 'tests'),
      ],
      exclude: /(node_modules)/,
      loader: 'babel',
    },
  ];

  return loaders;
}

I will be forever grateful to whoever can give me any pointers.


Solution

  • You can register handlebars helpers, apparently here.