Open reloaded opened 8 years ago
https://github.com/kangax/html-lint#usage is all there is. No configuration options at the moment.
Unlike html-minifier
, there isn't any plugins for this yet. Feel free to create something similar to gulp-htmlmin
or grunt-contrib-htmlmin
.
No idea what "template partials" mean, but as long as they are valid HTML it should parse okay.
Here is a Grunt plugin. Drop it directly into your Gruntfile.js
:
// Define the Lint HTML task.
grunt.registerMultiTask('linthtml', 'Lint HTML.', function() {
var lint = require('html-minifier-lint').lint,
filesToLint = grunt.file.expand(this.data.target),
errorOutput = '',
result;
if (!filesToLint.length) {
grunt.log.writeln('No HTML files found to lint.');
}
for (var i = 0, l = filesToLint.length; i < l; i++) {
result = lint(grunt.file.read(filesToLint[i]));
if (result) {
errorOutput += '\n' + filesToLint[i] + '\n' + result;
}
}
if (errorOutput) {
grunt.log.error(errorOutput.substring(1));
return false;
}
if (this.data.verbose) {
grunt.log.writeln('These HTML files validated successfully:\n - ' + filesToLint.join('\n - '));
}
else {
grunt.log.writeln('HTML validated successfully.');
}
});
And change your config:
grunt.initConfig({
linthtml: {
dev: {
target: ['app/**/*.html'], // array of file paths/globs of HTML files to lint
verbose: true, // optional, defaults to false
},
},
});
Where is the package documentation/usage?
Are there any Gulp/Grunt plugins?
Can html-lint correctly lint check Angular.js HTML template partials?