assemble-render-file
Advanced tools
Comparing version 0.7.2 to 1.0.0
54
index.js
/*! | ||
* assemble-render-file <https://github.com/jonschlinkert/assemble-render-file> | ||
* assemble-render-file <https://github.com/assemble/assemble-render-file> | ||
* | ||
* Copyright (c) 2015, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
* Copyright (c) 2015-2017, Jon Schlinkert. | ||
* Released under the MIT License. | ||
*/ | ||
@@ -52,3 +52,2 @@ | ||
var files = []; | ||
var handled = []; | ||
@@ -61,2 +60,7 @@ return utils.through.obj(function(file, enc, next) { | ||
if (utils.isBinary(file)) { | ||
next(null, file); | ||
return; | ||
} | ||
if (file.data.render === false || opts.render === false) { | ||
@@ -70,26 +74,39 @@ next(null, file); | ||
app.handleOnce('onLoad', file, function(err) { | ||
if (err) { | ||
handleError(app, err, file, files, next); | ||
return; | ||
} | ||
app.emit('_prepare', file); | ||
next(); | ||
}); | ||
}, function(cb) { | ||
var self = this; | ||
// run `onLoad` middleware | ||
app.handleOnce('onLoad', file, function(err, view) { | ||
if (err) return next(err); | ||
handled.push(view); | ||
utils.reduce(files, [], function(acc, file, next) { | ||
debug('renderFile, preRender: %s', file.path); | ||
debug('renderFile, preRender: %s', view.relative); | ||
resolveEngine(app, locals, engine); | ||
resolveEngine(app, locals, engine); | ||
if (!locals.engine && app.isFalse('engineStrict')) { | ||
next(null, view); | ||
self.push(file); | ||
next(); | ||
return; | ||
} | ||
// render the view | ||
app.render(view, locals, function(err, res) { | ||
// render the file | ||
app.render(file, locals, function(err, res) { | ||
if (typeof res === 'undefined' || err) { | ||
handleError(app, err, view, files, handled, next); | ||
handleError(app, err, file, files, next); | ||
return; | ||
} | ||
debug('renderFile, postRender: %s', view.relative); | ||
next(null, res); | ||
debug('renderFile, postRender: %s', file.relative); | ||
self.push(res); | ||
next(); | ||
}); | ||
}); | ||
}, cb); | ||
}); | ||
@@ -102,3 +119,3 @@ }); | ||
function handleError(app, err, view, files, handled, cb) { | ||
function handleError(app, err, view, files, next) { | ||
var last = files[files.length - 1]; | ||
@@ -109,7 +126,6 @@ if (!(err instanceof Error)) { | ||
err.files = files; | ||
err.handled = handled; | ||
err.view = last; | ||
err.path = last.path; | ||
app.emit('error', err); | ||
cb(err); | ||
next(err); | ||
} | ||
@@ -116,0 +132,0 @@ |
{ | ||
"name": "assemble-render-file", | ||
"description": "Assemble plugin for rendering views in a vinyl pipeline.", | ||
"version": "0.7.2", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/assemble/assemble-render-file", | ||
@@ -24,21 +24,23 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"is-valid-app": "^0.1.2", | ||
"lazy-cache": "^2.0.1", | ||
"async-array-reduce": "^0.2.1", | ||
"debug": "^2.6.0", | ||
"file-is-binary": "^0.2.2", | ||
"is-valid-app": "^0.2.1", | ||
"lazy-cache": "^2.0.2", | ||
"mixin-deep": "^1.1.3", | ||
"through2": "^2.0.1" | ||
"through2": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"assemble-fs": "^0.5.2", | ||
"assemble-streams": "^0.6.0", | ||
"assemble-fs": "^0.9.1", | ||
"assemble-streams": "^0.7.0", | ||
"engine-base": "^0.1.2", | ||
"engine-handlebars": "^0.8.0", | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^2.0.0", | ||
"gulp-format-md": "^0.1.9", | ||
"gulp-istanbul": "^1.0.0", | ||
"gulp-mocha": "^2.2.0", | ||
"mocha": "^2.5.3", | ||
"should": "^9.0.2", | ||
"templates": "^0.22.5" | ||
"gulp-eslint": "^3.0.1", | ||
"gulp-format-md": "^0.1.11", | ||
"gulp-istanbul": "^1.1.1", | ||
"gulp-mocha": "^3.0.1", | ||
"mocha": "^3.2.0", | ||
"should": "^11.2.0", | ||
"templates": "^1.2.2" | ||
}, | ||
@@ -48,11 +50,31 @@ "keywords": [ | ||
"assembleplugin", | ||
"boilerplate", | ||
"build", | ||
"cli", | ||
"cli-app", | ||
"command-line", | ||
"create", | ||
"dev", | ||
"development", | ||
"engine", | ||
"file", | ||
"framework", | ||
"front", | ||
"frontend", | ||
"plugin", | ||
"project", | ||
"projects", | ||
"render", | ||
"scaffold", | ||
"scaffolder", | ||
"scaffolding", | ||
"stream", | ||
"template", | ||
"templates", | ||
"view", | ||
"views", | ||
"vinyl" | ||
"vinyl", | ||
"webapp", | ||
"yeoman", | ||
"yo" | ||
], | ||
@@ -59,0 +81,0 @@ "verb": { |
@@ -1,4 +0,4 @@ | ||
# assemble-render-file [![NPM version](https://img.shields.io/npm/v/assemble-render-file.svg?style=flat)](https://www.npmjs.com/package/assemble-render-file) [![NPM downloads](https://img.shields.io/npm/dm/assemble-render-file.svg?style=flat)](https://npmjs.org/package/assemble-render-file) [![Build Status](https://img.shields.io/travis/assemble/assemble-render-file.svg?style=flat)](https://travis-ci.org/assemble/assemble-render-file) | ||
# assemble-render-file [![NPM version](https://img.shields.io/npm/v/assemble-render-file.svg?style=flat)](https://www.npmjs.com/package/assemble-render-file) [![NPM monthly downloads](https://img.shields.io/npm/dm/assemble-render-file.svg?style=flat)](https://npmjs.org/package/assemble-render-file) [![NPM total downloads](https://img.shields.io/npm/dt/assemble-render-file.svg?style=flat)](https://npmjs.org/package/assemble-render-file) [![Linux Build Status](https://img.shields.io/travis/assemble/assemble-render-file.svg?style=flat&label=Travis)](https://travis-ci.org/assemble/assemble-render-file) | ||
Assemble plugin for rendering views in a vinyl pipeline. | ||
> Assemble plugin for rendering views in a vinyl pipeline. | ||
@@ -56,39 +56,42 @@ ## Install | ||
## Related projects | ||
## About | ||
You might also be interested in these projects: | ||
### 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://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Assemble is a powerful, extendable and easy to use static site generator for node.js. Used by thousands of projects for much more than building websites, Assemble is also used for creating themes, scaffolds, boilerplates, e-books, UI components, API docum") | ||
* [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://github.com/assemble/assemble-loader) | [homepage](https://github.com/assemble/assemble-loader "Assemble plugin (^0.6.0) for loading globs of views onto custom view collections. Also works with verb or other Templates.js based applications.") | ||
* [assemble-streams](https://www.npmjs.com/package/assemble-streams): Assemble pipeline plugin for pushing a view collection into a vinyl stream. | [homepage](https://github.com/assemble/assemble-streams "Assemble pipeline plugin for pushing a view collection into a vinyl stream.") | ||
* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit") | ||
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://github.com/node-base/base) | [homepage](https://github.com/node-base/base "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.") | ||
* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.") | ||
## Contributing | ||
### Contributing | ||
This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit directly. Any changes to the readme must be made in [.verb.md](.verb.md). See [Building Docs](#building-docs). | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
Or visit the [verb-readme-generator](https://github.com/verbose/verb-readme-generator) project to submit bug reports or pull requests for the readme layout template. | ||
### Contributors | ||
## Building docs | ||
| **Commits** | **Contributor** | | ||
| --- | --- | | ||
| 60 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 11 | [doowb](https://github.com/doowb) | | ||
_(This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
### Building docs | ||
Generate readme and API documentation with [verb](https://github.com/verbose/verb): | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -g verb verb-readme-generator && verb | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
## Running tests | ||
### Running tests | ||
Install dev dependencies: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install && npm test | ||
``` | ||
## Author | ||
### Author | ||
@@ -98,11 +101,11 @@ **Jon Schlinkert** | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
## License | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/assemble/assemble-render-file/blob/master/LICENSE). | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
MIT | ||
*** | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on June 24, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 08, 2017._ |
@@ -11,2 +11,4 @@ 'use strict'; | ||
require('async-array-reduce', 'reduce'); | ||
require('file-is-binary', 'isBinary'); | ||
require('is-valid-app', 'isValid'); | ||
@@ -13,0 +15,0 @@ require('mixin-deep', 'merge'); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12036
134
0
109
7
+ Addedasync-array-reduce@^0.2.1
+ Addedfile-is-binary@^0.2.2
+ Addedasync-array-reduce@0.2.1(transitive)
+ Addedbuffer-alloc@1.2.0(transitive)
+ Addedbuffer-alloc-unsafe@1.1.0(transitive)
+ Addedbuffer-fill@1.0.0(transitive)
+ Addedfile-is-binary@0.2.3(transitive)
+ Addedis-valid-app@0.2.1(transitive)
+ Addedis-valid-instance@0.2.0(transitive)
+ Addedisbinaryfile@3.0.3(transitive)
- Removedis-valid-app@0.1.2(transitive)
- Removedis-valid-instance@0.1.0(transitive)
Updateddebug@^2.6.0
Updatedis-valid-app@^0.2.1
Updatedlazy-cache@^2.0.2
Updatedthrough2@^2.0.3