【发布时间】:2016-10-25 20:56:28
【问题描述】:
我是 Grunt 的新手,试图找到一种方法来加载多个 HTML 文件并解析它们以提取一些值。
我尝试使用jQuery.parseHTML、HTMLParser,但两者都没有定义。有没有办法包含 jQuery 或可以解析 HTML 的库?
grunt.config.init({
concat: {
options: {
dest: 'tmp',
templates: ['public/*.html']
}
}
});
var recursiveConcat = function(source, result){
grunt.file.expand(source).forEach(function(file){
var data = grunt.file.read(file);
// parse html to dom
result += data;
});
return result;
};
【问题讨论】:
-
Node 不是浏览器,所以它没有
window或document。即使你加载了 jQuery,你仍然没有 DOM 解析器。 -
这与 grunt 具体有什么关系?
标签: javascript jquery html parsing gruntjs