Comparing version 1.1.1 to 1.2.0
@@ -27,3 +27,5 @@ 'use strict'; | ||
try { | ||
file.contents = new Buffer(ejs.render(file.contents.toString(), options)); | ||
file.contents = new Buffer( | ||
ejs.render(file.contents.toString(), file.data || options) | ||
); | ||
file.path = gutil.replaceExtension(file.path, settings.ext); | ||
@@ -30,0 +32,0 @@ } catch (err) { |
{ | ||
"name": "gulp-ejs", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "A plugin for Gulp that parses ejs template files", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -51,2 +51,4 @@ # gulp-ejs [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
**Note:** As of `v1.2.0`, `file.data` is supported as a way of passing data into ejs. See [this](https://github.com/colynb/gulp-data#note-to-gulp-plugin-authors). | ||
#### settings | ||
@@ -53,0 +55,0 @@ Type: `hash` |
@@ -220,3 +220,35 @@ /*global describe, it*/ | ||
}); | ||
it('should support passing data with gulp-data', function (done) { | ||
var srcFile = new gutil.File({ path: 'test/fixtures/ok.ejs', | ||
cwd: 'test/', | ||
base: 'test/fixtures', | ||
contents: fs.readFileSync('test/fixtures/ok.ejs') | ||
}); | ||
// simulate gulp-data plugin | ||
srcFile.data = { title: 'gulp-ejs' }; | ||
var stream = ejs(); | ||
stream.on('error', function (err) { | ||
should.exist(err); | ||
done(err); | ||
}); | ||
stream.on('data', function (newFile) { | ||
should.exist(newFile); | ||
should.exist(newFile.contents); | ||
String(newFile.contents).should.equal(String(expectedFile.contents)); | ||
done(); | ||
}); | ||
stream.write(srcFile); | ||
String(path.extname(srcFile.path)).should.equal('.html'); | ||
stream.end(); | ||
}); | ||
}); | ||
}); |
14213
233
78