index.js
function templatesFromStream(templateStream) {
        var firstTemplate = null;
        templateStream.on('data', function(file) {
            var relpath = file.relative;
            var deferred;
            if (registry.hasOwnProperty(relpath)) {
                deferred = registry[relpath];
            } else {
                deferred = registry[relpath] = new Deferred();
            }
            try {
                if (!file.isBuffer()) {
                    throw pluginError('Template source must be buffer');
                }
                var template = compile({
                    data: file.contents.toString(),
                    name: file.path,
                    path: file.path
                });
                deferred.resolve(template);
                if (firstTemplate === null) {
                    firstTemplate = template;
                } else {
                    firstTemplate = false;
                    theOnlyTemplate.reject(pluginError('Multiple templates given, must select one'));
                }
            } catch(err) {
                deferred.reject(err);
            }
        }).on('end', function() {
            if (firstTemplate)
                theOnlyTemplate.resolve(firstTemplate);
            else
                theOnlyTemplate.reject(pluginError('No templates in template stream'));
            noMoreTemplates();
        }).on('error', function(err) {
            templateStreamError = err;
            noMoreTemplates();
        });
    }
function templatesFromStream(templateStream) {
        var firstTemplate = null;
        templateStream.on('data', function(file) {
            var relpath = file.relative;
            var deferred;
            if (registry.hasOwnProperty(relpath)) {
                deferred = registry[relpath];
            } else {
                deferred = registry[relpath] = new Deferred();
            }
            try {
                if (!file.isBuffer()) {
                    throw pluginError('Template source must be buffer');
                }
                var template = compile({
                    data: file.contents.toString(),
                    name: file.path,
                    path: file.path
                });
                deferred.resolve(template);
                if (firstTemplate === null) {
                    firstTemplate = template;
                } else {
                    firstTemplate = false;
                    theOnlyTemplate.reject(pluginError('Multiple templates given, must select one'));
                }
            } catch(err) {
                deferred.reject(err);
            }
        }).on('end', function() {
            if (firstTemplate)
                theOnlyTemplate.resolve(firstTemplate);
            else
                theOnlyTemplate.reject(pluginError('No templates in template stream'));
            noMoreTemplates();
        }).on('error', function(err) {
            templateStreamError = err;
            noMoreTemplates();
        });
    }
Read templates from a gulp stream