Comparing version 2.1.3 to 2.2.0
@@ -6,2 +6,3 @@ 'use strict'; | ||
var ejs = require('ejs'); | ||
var assign = require('object-assign'); | ||
@@ -25,3 +26,3 @@ module.exports = function (options, settings) { | ||
options = file.data || options; | ||
options = assign({}, options, file.data); | ||
options.filename = file.path; | ||
@@ -28,0 +29,0 @@ |
{ | ||
"name": "gulp-ejs", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"description": "A plugin for Gulp that parses ejs template files", | ||
@@ -28,7 +28,8 @@ "keywords": [ | ||
"gulp-util": "3.0.7", | ||
"object-assign": "^4.1.0", | ||
"through2": "2.0.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "2.5.3", | ||
"should": "10.0.0" | ||
"mocha": "3.0.2", | ||
"should": "11.1.0" | ||
}, | ||
@@ -35,0 +36,0 @@ "engines": { |
@@ -49,5 +49,5 @@ # gulp-ejs [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url] | ||
For more info on `ejs` options, check the [project's documentation](https://github.com/visionmedia/ejs). | ||
For more info on `ejs` options, check the [project's documentation](https://github.com/mde/ejs). | ||
**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). | ||
**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). If both `file.data` and `options` are passed, they are merged (`options` works as default for ejs options and `file.data` overrides it.) | ||
@@ -54,0 +54,0 @@ #### settings |
@@ -126,6 +126,3 @@ /*global describe, it*/ | ||
var current = newFile.contents.toString().replace(/\r?\n|\r/g, ''); | ||
var expected = expectedFileWithPartial.contents.toString().replace(/\r?\n|\r/g, ''); | ||
current.should.equal(expected); | ||
String(newFile.contents).should.equal(String(expectedFileWithPartial.contents)); | ||
done(); | ||
@@ -163,3 +160,3 @@ }); | ||
stream.end(); | ||
}) | ||
}); | ||
@@ -198,2 +195,32 @@ it('should support passing data with gulp-data', function (done) { | ||
it('should merge options and file.data when both are passed', function (done) { | ||
var srcFile = new gutil.File({ | ||
path: 'test/fixtures/withpartial.ejs', | ||
cwd: 'test/', | ||
base: 'test/fixtures', | ||
contents: fs.readFileSync('test/fixtures/withpartial.ejs') | ||
}); | ||
// simulate gulp-data plugin | ||
srcFile.data = { name: 'rpvl' }; | ||
var stream = ejs({ msg: 'gulp-ejs', name: 'foo' }); | ||
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(expectedFileWithPartial.contents)); | ||
done(); | ||
}); | ||
stream.write(srcFile); | ||
stream.end(); | ||
}); | ||
describe('with assets', function () { | ||
@@ -221,3 +248,3 @@ it('should templating with javascripts', function (done) { | ||
should.exist(newFile.contents); | ||
path.extname(newFile.path).should.equal('.js') | ||
path.extname(newFile.path).should.equal('.js'); | ||
@@ -252,3 +279,3 @@ String(newFile.contents).should.equal(fs.readFileSync('test/expected/config.js', 'utf8')); | ||
should.exist(newFile.contents); | ||
path.extname(newFile.path).should.equal('.css') | ||
path.extname(newFile.path).should.equal('.css'); | ||
@@ -255,0 +282,0 @@ String(newFile.contents).should.equal(fs.readFileSync('test/expected/head.css', 'utf8')); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15560
261
4
+ Addedobject-assign@^4.1.0