Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-ejs

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-ejs - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

test/expected/outputWithPartial.html

24

index.js
'use strict';
var es = require('event-stream');
var through = require('through2');
var gutil = require('gulp-util');

@@ -12,12 +12,26 @@ var ejs = require('ejs');

return es.map(function (file, cb) {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit(
'error',
new gutil.PluginError('gulp-ejs', 'Streaming not supported')
);
}
options.filename = options.filename || file.path;
try {
options.filename = options.filename || file.path;
file.contents = new Buffer(ejs.render(file.contents.toString(), options));
file.path = gutil.replaceExtension(file.path, settings.ext);
} catch (err) {
return cb(new gutil.PluginError('gulp-ejs', err));
this.emit('error', new gutil.PluginError('gulp-ejs', err.toString()));
}
cb(null, file);
this.push(file);
cb();
});
};
{
"name": "gulp-ejs",
"version": "0.1.5",
"version": "0.2.0",
"description": "A plugin for Gulp that parses ejs template files",

@@ -26,9 +26,9 @@ "keywords": [

"dependencies": {
"event-stream": "*",
"gulp-util": "~2.2.6",
"ejs": "~0.8.5"
"gulp-util": "^2.2.14",
"ejs": "^0.8.5",
"through2": "^0.4.1"
},
"devDependencies": {
"mocha": "~1.14.0",
"should": "~2.1.0"
"should": "^2.1.1",
"mocha": "^1.14.0"
},

@@ -35,0 +35,0 @@ "engines": {

@@ -24,3 +24,17 @@ # gulp-ejs [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]

```
If you want to use `gulp-ejs` in a watch/livereload task, you may want to avoid gulp exiting on error when, for instance, a partial file is `ENOENT`.
Here's an example on how to make it work:
```javascript
var ejs = require('gulp-ejs');
var gutil = require('gulp-util');
gulp.src('./templates/*.ejs')
.pipe(ejs({
msg: 'Hello Gulp!'
}).on('error', gutil.log))
.pipe(gulp.dest('./dist'));
```
This will make gulp log the error and continue normal execution.
## API

@@ -27,0 +41,0 @@

@@ -21,2 +21,9 @@ /*global describe, it*/

var expectedFileWithPartial = new gutil.File({
path: 'test/expected/outputWithPartial.html',
cwd: 'test/',
base: 'test/expected',
contents: fs.readFileSync('test/expected/outputWithPartial.html')
});
it('should produce correct html output when rendering a file', function (done) {

@@ -103,2 +110,27 @@

});
it('should produce correct html output using partial', function (done) {
var srcFile = new gutil.File({
path: 'test/fixtures/withpartial.ejs',
cwd: 'test/',
base: 'test/fixtures',
contents: fs.readFileSync('test/fixtures/withpartial.ejs')
});
var stream = ejs({ title: 'gulp-ejs', msg: 'gulp-ejs', name: 'rpvl' });
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();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc