在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:karma-runner/karma-html2js-preprocessor开源软件地址:https://github.com/karma-runner/karma-html2js-preprocessor开源编程语言:CoffeeScript 54.3%开源软件介绍:karma-html2js-preprocessor
Note: If you are using AngularJS, check out karma-ng-html2js-preprocessor. InstallationThe easiest way is to keep {
"devDependencies": {
"karma": "~0.10",
"karma-html2js-preprocessor": "~0.1"
}
} You can simple do it by: npm install karma-html2js-preprocessor --save-dev Configuration// karma.conf.js
module.exports = function(config) {
config.set({
preprocessors: {
'**/*.html': ['html2js']
},
files: [
'*.js',
'*.html'
],
html2JsPreprocessor: {
// strip this from the file path
stripPrefix: 'public/',
// prepend this to the file path
prependPrefix: 'served/',
// or define a custom transform function
processPath: function(filePath) {
// Drop the file extension
return filePath.replace(/\.html$/, '');
}
}
});
}; How does it work ?This preprocessor converts HTML files into JS strings and publishes them in the global For instance this <div>something</div> ... will be served as window.__html__ = window.__html__ || {};
window.__html__['template.html'] = '<div>something</div>'; See the end2end test for a complete example. For more information on Karma see the homepage. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论