karma-handlebars-preprocessor
Preprocessor to compile Handlebars on the fly.
Forked from hanachin's code (kudos!)
Works with Karma 0.9 or later.
For more information on Karma see the homepage.
Installation
- Install karma-handlebars-preprocessor plugin.
$ npm install karma-handlebars-preprocessor --save-dev
- Define it as a preprocessor in the config file
preprocessors: {
'**/*.hbs': 'handlebars'
}
or pass through the command line
$ karma start --preprocessors handlebars
Configuration
You can configure default behaviour in the handlebarsPreprocessor
section of the config file. The following shows the default implementation:
module.exports = function(config) {
config.set({
preprocessors: {
'**/*.hbs': ['handlebars']
},
handlebarsPreprocessor: {
templates: "Handlebars.templates",
templateName: function(filepath) {
return filepath.replace(/^.*\/([^\/]+)\.hbs$/, '$1');
},
transformPath: function(path) {
return path.replace(/\.hbs$/, '.js');
}
}
});
};
License
MIT License