0.0.1 • Published 6 years ago
gulp-htm-include v0.0.1
gulp-html-include
a gulp-html-include plugin
- 引入html文件,支持<?html>、、
- 传递参数,emit通信
Usage
github下载
git clone "https://github.com/dingjiamughal/gulp-html-include.git"
npm下载
npm install gulp-html-include --save-dev
在 gulpfile.js
中引入:
var htmlInclude = require('gulp-html-include');
gulp.task('include', function () {
gulp.src(srcPath + 'view/**/*.html')
.pipe(htmlInclude('template/**/*.html'))
.pipe(gulp.dest(prdPath+'view'));
});
//监听文件热更新
gulp.watch(srcPath + 'views/**/*.html', ['include']);
Example
|
-- views
| |
| -- index.html
| |
| |
-- template
| |
| -- header.html
| |
| -- footer.html
|
|
-- gulpfile.js
Html files:
<!-- index.html -->
<body>
@include "header.html"
<p>Hello World</p>
@include "footer.html"
</body>
In your index.html
, you should use
@include "XXX.html"
to include your components in dir---template.
<!-- header.html -->
<h1>I am the header</h1>
<!-- footer.html -->
<h1>I am the footer</h1>
gulp include
<!-- 打包之后的效果 -->
<body>
<h1>I am the header</h1>
<p>Hello World</p>
<h1>I am the footer</h1>
</body>
API
htmlImport(string)
string
Type: String
template中引用的文件路径
Copyright © 2017 dingjia
0.0.1
6 years ago