Preprocessor to compile Pug templates on the fly.
The easiest way is to keep karma-pug-preprocessor
as a devDependency in your package.json
.
{
"devDependencies": {
"karma": "1.7.0",
"karma-pug-preprocessor": "1.0.0-beta.2"
}
}
You can simple do it by:
npm install karma-pug-preprocessor --save-dev
Following code shows the default configuration...
// karma.conf.js
module.exports = function(config) {
config.set({
preprocessors: {
'**/*.pug': ['pug']
}
});
};
As with other preprocessors, One can further configure the options passed to Pug either by adding an extra property to your karma.conf.js
:
pugPreprocessor: {
options: {
pretty: false
}
}
Or by abstracting this into a custom preprocessor:
customPreprocessors: {
myPug: {
base: 'pug',
options: {pretty: false}
}
}
The pug preprocessor can be used in conjunction with others (eg. karma-ng-html2js-preprocessor). Simply include it in an array that specifies the chain of processors.
// karma.conf.js
module.exports = function(config) {
config.set({
preprocessors: {
'**/*.pug': ['pug', 'ng-html2js']
}
});
};
For more information on Karma see the homepage.