我已按照有关如何安装它的说明进行操作,我的 Gruntfile.js 现在如下所示:
module.exports = function(grunt){
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
htmlhint: {
build: {
options: {
'tag-pair': true,
'tagname-lowercase': true,
'attr-lowercase': true,
'attr-value-double-quotes': true,
'doctype-first': true,
'spec-char-escape': true,
'id-unique': true,
'head-script-disabled': true,
'style-disabled': true
},
src: ['index.html']
}
}
});
grunt.registerTask('default', []);
};
我想定位项目文件夹中的所有 .html 文件,该文件夹由带有 html 的不同目录组成。
我如何定位所有这些?
最佳答案
您可以在 src
部分使用通配符。
来自 htmlhint docs :
htmlhint: {
html1: {
options: {
'tag-pair': true
},
src: ['path/to/**/*.html']
}
}
以上代码将定位指定路径内任何目录中的任何 .html 文件。
您还可以指定多个路径,如下所示:
src: ['dir1/*.html', 'dir2/*.html', 'dir3/**/*.html']
关于javascript - Grunt.js : htmlhint - targeting all html files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26323210/