使用 Grunt 检索 html 正文的内容
Retrieving the contents of the html body using Grunt
是否有 grunt 任务可以获取 html 正文的内容并将其放入单独的文件中?
<html>
<body>
<h1>Grab this</h1>
<h2>And this</h2>
</body>
</html>
您可以使用 Grunt 的 Copy Part of File 到 select 正文。
文档在这里。
https://www.npmjs.com/package/grunt-copy-part-of-file
例如
grunt.initConfig({
copy_part_of_file: {
simple_replace_scripts: {
options: {
sourceFileStartPattern: '<body>',
sourceFileEndPattern: '</body>',
destinationFileStartPattern: '',
destinationFileEndPattern: ''
},
files: {
'test/fixtures/simple-destination.html': ['test/fixtures/simple-source.html']
}
}
},
})
是否有 grunt 任务可以获取 html 正文的内容并将其放入单独的文件中?
<html>
<body>
<h1>Grab this</h1>
<h2>And this</h2>
</body>
</html>
您可以使用 Grunt 的 Copy Part of File 到 select 正文。
文档在这里。 https://www.npmjs.com/package/grunt-copy-part-of-file
例如
grunt.initConfig({
copy_part_of_file: {
simple_replace_scripts: {
options: {
sourceFileStartPattern: '<body>',
sourceFileEndPattern: '</body>',
destinationFileStartPattern: '',
destinationFileEndPattern: ''
},
files: {
'test/fixtures/simple-destination.html': ['test/fixtures/simple-source.html']
}
}
},
})