1.0.11 • Published 7 years ago
gulp-hi v1.0.11
gulp-handlebars-include
###Install: Install with npm.
npm i gulp-hi --save-dev
###Examples:
var gulp = require('gulp');
var hi = require('gulp-hi');
gulp.task('default', function () {
gulp.src('app/html/*.html')
.pipe(hi())
.pipe(gulp.dest('app/'));
});
###How use it in sources: app/html/index.html
<body>
{{ include="app/html/tpl/header.html" class="my-class" data="my-data" title="My Title" }}
</body>
app/html/tpl/header.html example of use handlebars
<div class="header {{ class }}">
{{ if data }}
<div class="data" data-my="{{ data }}">{{ title }}</div>
{{ /if }}
</div>
Result after compile app/index.html
<body>
<div class="header my-class">
<div class="data" data-my="my-data">My Title</div>
</div>
</body>
###Options:
tplDir - static directory fo templates. Default '/'. Example:
gulpfile.js
gulp.task('default', function () {
gulp.src('app/html/*.html')
.pipe(hi({tplDir: '/app/html/tpl/'}))
.pipe(gulp.dest('app/'));
});
app/html/index.html
<body>
{{ include="header.html" class="my-class" data="my-data" title="My Title" }}
</body>
quotes - single or double. Default double. Example:
gulpfile.js
gulp.task('default', function () {
gulp.src('app/html/*.html')
.pipe(hi({quotes: 'single'}))
.pipe(gulp.dest('app/'));
});
app/html/index.html
<body>
{{ include='header.html'
link='<a href="#link">Link</a>'
arr=['one', 'two', 'three']}}
</body>