function render( options, context ){ var adapter = dustin(options) return through.obj(function( file, enc, done ){ if ( file.isNull() ) return // ignore if ( file.isStream() ) return this.emit("error", new PluginError("gulp-concat", "Streaming not supported")) var stream = this adapter.renderSource(file.contents.toString(), context, function( err, rendered ){ if( err ) return done(err) var renderedFile = new File({ cwd: file.cwd, base: file.base, path: gutil.replaceExtension(file.path, ".html"), contents: new Buffer(rendered) }) stream.push(renderedFile) done(err) }) }) }
function compile( options ){ var adapter = dustin(options) return through.obj(function( file, enc, done ){ if ( file.isNull() ) return // ignore if ( file.isStream() ) return this.emit("error", new PluginError("gulp-concat", "Streaming not supported")) var stream = this var templateName = adapter.getTemplateNameFromPath(file.path) var compiled = adapter.compile(file.contents.toString(), templateName) var compiledFile = new File({ cwd: file.cwd, base: file.base, path: gutil.replaceExtension(file.path, ".js"), contents: new Buffer(compiled) }) stream.push(compiledFile) done() }) }