-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 774 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var through = require('through2'),
handlebars = require('handlebars'),
gutil = require('gulp-util'),
PluginError = gutil.PluginError;
module.exports = function (data) {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit(
'error',
new gutil.PluginError('gulp-handlebars-render', 'Streaming not supported')
);
}
var template = handlebars.compile(file.contents.toString());
file.contents = new Buffer(template(data));
file.path = gutil.replaceExtension(file.path, '.html');
this.push(file);
cb();
});
};