gulp-htmlincluder = function (insertText) { "use strict"; var that; includer.initialize(); function htmlincluder() { includer.buildHtml(function(file) { var f = file.file; f.contents = new Buffer(file.content); that.push(f); }); } function aggregateFiles(file, enc, callback) { that = this; //defined in scope of module // Do nothing if no contents if (file.isNull()) { this.push(file); return callback(); } if (file.isStream()) { this.emit("error", new gutil.PluginError("gulp-htmlincluder", "Stream content is not supported")); return callback(); } if (file.isBuffer()) { includer.hashFile(file, insertText); } return callback(); } return through.obj(aggregateFiles, htmlincluder); }
n/a
function buildHtml(callback) { return pageFiles.map(function(file) { processFile(file); if(callback) { callback(file); } return file; }); }
...
module.exports = function (insertText) {
"use strict";
var that;
includer.initialize();
function htmlincluder() {
includer.buildHtml(function(file) {
var f = file.file;
f.contents = new Buffer(file.content);
that.push(f);
});
}
...
function hashFile(file, insTxt) { var f = File(file); //set text value for insert tags, or default insertText = (insTxt) ? '<!--#' + insTxt : '<!--#insert'; processClip(f); if(f.name[0] === '_') wrapFiles[f.path] = f; else if(f.name[0] === '-') insertFiles[f.path] = f; else pageFiles.push(f); }
...
if (file.isStream()) {
this.emit("error",
new gutil.PluginError("gulp-htmlincluder", "Stream content is not supported"));
return callback();
}
if (file.isBuffer()) {
includer.hashFile(file, insertText);
}
return callback();
}
return through.obj(aggregateFiles, htmlincluder);
};
...
function initialize() { //reset vars in case these had kept their value in closure wrapFiles = {}; insertFiles = {}; pageFiles = []; }
...
// @insertText = (optional) the test looked for in order to insert files
// (this is so ssi includes can be used instead)
//
module.exports = function (insertText) {
"use strict";
var that;
includer.initialize();
function htmlincluder() {
includer.buildHtml(function(file) {
var f = file.file;
f.contents = new Buffer(file.content);
that.push(f);
...