+4
-3
@@ -7,9 +7,10 @@ 'use strict'; | ||
| module.exports = function(data) { | ||
| module.exports = function(data, options, extension) { | ||
| data = data || {}; | ||
| extension = extension || '.js'; | ||
| return es.map(function (file, cb) { | ||
| file.contents = new Buffer( Hogan.compile(file.contents.toString()).render(data) ); | ||
| file.path = gutil.replaceExtension(file.path, '.js'); | ||
| file.contents = new Buffer( Hogan.compile(file.contents.toString(), options).render(data) ); | ||
| file.path = gutil.replaceExtension(file.path, extension); | ||
| cb(null,file); | ||
| }); | ||
| }; |
+1
-1
| { | ||
| "name": "gulp-hogan", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "description": "gulp plugin to compile mustache templates", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+31
-5
@@ -6,2 +6,10 @@ 'use strict'; | ||
| function fixture(stream, content) | ||
| { | ||
| stream.write(new gutil.File({ | ||
| path: 'fixture.hogan', | ||
| contents: new Buffer(content) | ||
| })); | ||
| } | ||
| it('should compile hogan to js', function (cb) { | ||
@@ -15,7 +23,25 @@ var stream = hogan({handle: 'gnumanth'}); | ||
| }); | ||
| fixture(stream, '{{handle}}'); | ||
| }); | ||
| stream.write(new gutil.File({ | ||
| path: 'fixture.hogan', | ||
| contents: new Buffer('{{handle}}') | ||
| })); | ||
| }); | ||
| it('should support custom delimiters', function (cb) { | ||
| var stream = hogan({handle: 'gnumanth'}, {delimiters: '<% %>'}); | ||
| stream.on('data', function (file) { | ||
| assert.equal(file.relative, 'fixture.js'); | ||
| assert.equal(file.contents.toString(), 'gnumanth'); | ||
| cb(); | ||
| }); | ||
| fixture(stream, '<% handle %>'); | ||
| }); | ||
| it('should support custom extensions', function (cb) { | ||
| var stream = hogan({handle: 'gnumanth'}, null, '.html'); | ||
| stream.on('data', function (file) { | ||
| assert.equal(file.relative, 'fixture.html'); | ||
| assert.equal(file.contents.toString(), 'gnumanth'); | ||
| cb(); | ||
| }); | ||
| fixture(stream, '{{handle}}'); | ||
| }); |
3354
37.63%50
85.19%