return through2.obj(function(file, enc, cb) { var _fp = file.path, _data = data || {}; if (file.isNull()) { cb(null, file); return; } if (file.isStream()) { cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported')); return; } if (file.data) { _data = _.extend(file.data, _data); } try { file.contents = new Buffer(teddy.render(_fp, _data)); cb(null, file); } catch (err) { cb(new gutil.PluginError(PLUGIN_NAME, err, { fileName: _fp })); } });
return through2.obj((file, enc, cb) => { if (file.isNull()) { return cb(null, file); } let _data = data || {}; if (file.data) { _data = extend(true, file.data, _data); } if (file.isBuffer()) { file.contents = new Buffer(teddy.render(file.contents.toString(), _data)); } if (file.isStream()) { file.contents = file.contents.pipe(through2.obj((template, enc, callback) => { callback(null, teddy.render(template.toString(), _data)); })); } cb(null, file); });
file.contents = file.contents.pipe(through2.obj((template, enc, callback) => { callback(null, teddy.render(template.toString(), _data)); }));