安装
npm install gulp-content-includer
使用
var gulp = require(‘gulp‘); var contentIncluder = require(‘gulp-content-includer‘); var rename = require(‘gulp-rename‘); gulp.task(‘concat‘,function() { gulp.src("./content.html") .pipe(contentIncluder({ includerReg:/<!\-\-include\s+"([^"]+)"\-\->/g })) .pipe(rename(‘index.html‘)) .pipe(gulp.dest(‘./‘)); });
说明
include语句模板自己随便定,只要把解析语句的正则传进去就行了,例:
<!--include "./footer.html"-->
时间: 2024-10-12 08:16:24