assemble-render-file
Advanced tools
Comparing version 0.3.0 to 0.3.1
32
index.js
@@ -41,4 +41,3 @@ /*! | ||
var collection = app.collection(opts); | ||
var File = opts.File || app.View; | ||
var View = opts.View || opts.File || app.View; | ||
@@ -50,5 +49,3 @@ return utils.through.obj(function(file, enc, next) { | ||
if (!file.isView) { | ||
file = collection.view(file); | ||
} | ||
if (!file.isView) file = new View(file); | ||
@@ -60,4 +57,9 @@ // run `onLoad` middleware | ||
var ctx = utils.merge({}, app.cache.data, locals, file.data); | ||
ctx.engine = engine || ctx.engine; | ||
ctx.engine = resolveEngine(app, ctx, engine); | ||
if (!ctx.engine && app.option('engineStrict') === false) { | ||
next(null, file); | ||
return; | ||
} | ||
// render the file | ||
@@ -71,7 +73,4 @@ app.render(file, ctx, function(err, res) { | ||
var view = new File(res); | ||
if (typeof engine === 'string') { | ||
delete view.fn; | ||
} | ||
next(null, view); | ||
if (engine) delete res.fn; | ||
next(null, res); | ||
}); | ||
@@ -82,1 +81,12 @@ }); | ||
}; | ||
function resolveEngine(app, ctx, engine) { | ||
ctx.engine = engine || ctx.engine; | ||
// allow a `noop` engine to be defined | ||
if (!ctx.engine && app.engines['.noop']) { | ||
ctx.engine = '.noop'; | ||
} | ||
return ctx.engine; | ||
} |
{ | ||
"name": "assemble-render-file", | ||
"description": "Assemble plugin for rendering views in a vinyl pipeline.", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"homepage": "https://github.com/jonschlinkert/assemble-render-file", | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"repository": "jonschlinkert/assemble-render-file", | ||
"bugs": "https://github.com/jonschlinkert/assemble-render-file/issues", | ||
"bugs": { | ||
"url": "https://github.com/jonschlinkert/assemble-render-file/issues" | ||
}, | ||
"license": "MIT", | ||
@@ -22,3 +24,3 @@ "files": [ | ||
"dependencies": { | ||
"lazy-cache": "^0.2.4", | ||
"lazy-cache": "^1.0.3", | ||
"mixin-deep": "^1.1.3", | ||
@@ -28,3 +30,3 @@ "through2": "^2.0.0" | ||
"devDependencies": { | ||
"assemble-core": "^0.2.0", | ||
"assemble-core": "^0.8.0", | ||
"engine-base": "^0.1.2", | ||
@@ -36,4 +38,4 @@ "engine-handlebars": "^0.8.0", | ||
"gulp-mocha": "^2.2.0", | ||
"mocha": "^2.3.4", | ||
"should": "^7.1.1" | ||
"mocha": "*", | ||
"should": "*" | ||
}, | ||
@@ -40,0 +42,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# assemble-render-file [![NPM version](https://badge.fury.io/js/assemble-render-file.svg)](http://badge.fury.io/js/assemble-render-file) | ||
# assemble-render-file [![NPM version](https://img.shields.io/npm/v/assemble-render-file.svg)](https://www.npmjs.com/package/assemble-render-file) [![Build Status](https://img.shields.io/travis/jonschlinkert/assemble-render-file.svg)](https://travis-ci.org/jonschlinkert/assemble-render-file) | ||
@@ -10,5 +10,4 @@ > Assemble plugin for rendering views in a vinyl pipeline. | ||
## Install | ||
Install with [npm](https://www.npmjs.com/): | ||
Install with [npm](https://www.npmjs.com/) | ||
```sh | ||
@@ -34,10 +33,35 @@ $ npm i assemble-render-file --save | ||
### noop engine | ||
By default, when no engine is found for a file an error is thrown. To get around this you can either define a `noop` engine, or use disable the [engineStrict option](#optionsengineStrict). | ||
A noop engine follows the same signature as any engine, but must be registered using the key: `noop`. | ||
**Example** | ||
```js | ||
app.engine('noop', function(view, opts, next) { | ||
// do whatever you want to `view`, or nothing | ||
next(null, view); | ||
}); | ||
``` | ||
## Options | ||
### options.engineStrict | ||
By default, when no engine is found for a file an error is thrown. This can be disabled with the following: | ||
```js | ||
app.option('engineStrict', false); | ||
``` | ||
When disabled and an engine is not found, files are just passed through. | ||
## Related projects | ||
* [assemble](https://www.npmjs.com/package/assemble): Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… [more](https://www.npmjs.com/package/assemble) | [homepage](https://github.com/assemble/assemble) | ||
* [assemble-loader](https://www.npmjs.com/package/assemble-loader): Assemble plugin (^0.6.0) for loading globs of views onto custom view collections. Also works with… [more](https://www.npmjs.com/package/assemble-loader) | [homepage](https://github.com/jonschlinkert/assemble-loader) | ||
* [assemble-streams](https://www.npmjs.com/package/assemble-streams): Assemble plugin that adds convenience methods for working with streams, like `toStream`, which pushes a… [more](https://www.npmjs.com/package/assemble-streams) | [homepage](https://github.com/jonschlinkert/assemble-streams) | ||
* [assemble](https://www.npmjs.com/package/assemble): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](https://www.npmjs.com/package/assemble) | [homepage](http://assemble.io) | ||
* [assemble-loader](https://www.npmjs.com/package/assemble-loader): Assemble plugin (0.6+) for loading globs of views onto custom view collections. Also works with… [more](https://www.npmjs.com/package/assemble-loader) | [homepage](https://github.com/jonschlinkert/assemble-loader) | ||
* [assemble-streams](https://www.npmjs.com/package/assemble-streams): Assemble plugin that adds convenience methods for working with streams, like `toStream`, which pushes a… [more](https://www.npmjs.com/package/assemble-streams) | [homepage](https://github.com/jonschlinkert/assemble-streams) | ||
## Running tests | ||
Install dev dependencies: | ||
@@ -50,7 +74,5 @@ | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/assemble-render-file/issues/new). | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](/new). | ||
## Author | ||
**Jon Schlinkert** | ||
@@ -62,4 +84,3 @@ | ||
## License | ||
Copyright © 2015 Jon Schlinkert | ||
Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert) | ||
Released under the MIT license. | ||
@@ -69,2 +90,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 17, 2015._ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on January 06, 2016._ |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
7547
84
87
+ Addedlazy-cache@1.0.4(transitive)
- Removedlazy-cache@0.2.7(transitive)
Updatedlazy-cache@^1.0.3