I'm using this handlebars-loader for webpack 4. Now I wanted to use a custom helper, but i only get this error
ERROR in Template execution failed: TypeError: __default(...).call is not a function
ERROR in TypeError: __default(...).call is not a function
this is my webpack.config
//handlebars-loader
{
test: /\.(hbs)$/,
loader: "handlebars-loader",
options: {
helperDirs: [path.join(__dirname, './src/hbs/helpers')],
partialDirs: [path.join(__dirname, './src/hbs/partials')]
},
}
and this is my simple helper
const Handlebars = require('handlebars');
Handlebars.registerHelper('repeat', function(n) {
console.log(n);
});
and how I use it
{{#repeat 10}}
<span> repeat</span>
{{/repeat}}
Does anyone know what I'm doing wrong?
Thank you, Gregor! This has been frustrating me all day!
I had a simple function in a helper file, checkActive.js :
This would not work and gave me this error:
I found your solution and tried it. Lo-and-behold it worked! This is what I am now using instead:
In order for this to work, you need to have the function saved in a file with the same name as the handlebars helper function you are calling, ie. in my case: checkActive.js