{"name":"vinyl-view","description":"Extends vinyl with render and compile methods, and properties used for rendering templates.","version":"2.0.0","homepage":"https://github.com/jonschlinkert/vinyl-view","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/vinyl-view.git"},"bugs":{"url":"https://github.com/jonschlinkert/vinyl-view/issues"},"license":"MIT","files":["index.js","utils.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"arr-union":"^3.1.0","define-property":"^0.2.5","engine-base":"^0.1.2","isobject":"^3.0.0","lazy-cache":"^2.0.2","mixin-deep":"^1.1.3","vinyl-item":"^1.0.0"},"devDependencies":{"event-stream":"^3.3.4","gulp-format-md":"^0.1.11","mocha":"^3.2.0"},"keywords":["assemble","collection","compile","context","engine","handlebars","render","template","templates","view","views","vinyl"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"reflinks":["verb","vinyl"],"lint":{"reflinks":true}},"gitHead":"da68726b9602e7cf53f7a6a84391878b225ae779","_id":"vinyl-view@2.0.0","_shasum":"d02d7a4cfe35c6361eac602b1791e3867e5e5efe","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"d02d7a4cfe35c6361eac602b1791e3867e5e5efe","tarball":"http://registry-npm.ywwl.com/vinyl-view/download/vinyl-view-2.0.0.tgz","integrity":"sha512-8M70GnEocL4tr2571q+oaxrbypWRsfi7q69eE0NpM84Y+IkQL/2kzSyGVyZLoQFfroGd88TtZl8Y09uDn/Lvdg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDOXi0YYKmrHd+1xDkAZ+Asn1l54KC3vofIcXmXoeuGlAiEAjTv79xQgCnQlSzwYdJe+qMJCRGD0ywuWXcPwcGgSM1o="}],"size":4663,"noattachment":false,"key":"/vinyl-view/-/vinyl-view-2.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/vinyl-view-2.0.0.tgz_1486597186339_0.010268477024510503"},"directories":{},"readme":"# vinyl-view [![NPM version](https://img.shields.io/npm/v/vinyl-view.svg?style=flat)](https://www.npmjs.com/package/vinyl-view) [![NPM monthly downloads](https://img.shields.io/npm/dm/vinyl-view.svg?style=flat)](https://npmjs.org/package/vinyl-view)  [![NPM total downloads](https://img.shields.io/npm/dt/vinyl-view.svg?style=flat)](https://npmjs.org/package/vinyl-view) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/vinyl-view.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/vinyl-view)\n\n> Extends vinyl with render and compile methods, and properties used for rendering templates.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save vinyl-view\n```\n\n## Usage\n\nUse the same way you would use a [vinyl](https://github.com/gulpjs/vinyl) file:\n\n```js\nvar View = require('vinyl-view');\nvar view = new View({path: 'foo'});\n```\n\n## API\n\n### [View](index.js#L26)\n\nCreate an instance of `View`. Optionally pass a default object to use.\n\n**Params**\n\n* `view` **{Object}**\n\n**Example**\n\n```js\nvar view = new View({\n  path: 'foo.html',\n  contents: new Buffer('...')\n});\n```\n\n### [.compile](index.js#L57)\n\nSynchronously compile a view.\n\n**Params**\n\n* `locals` **{Object}**: Optionally pass locals to the engine.\n* `returns` **{Object}** `View`: instance, for chaining.\n\n**Example**\n\n```js\nvar view = page.compile();\nview.fn({title: 'A'});\nview.fn({title: 'B'});\nview.fn({title: 'C'});\n```\n\n### [.renderSync](index.js#L75)\n\nSynchronously render templates in `view.content`.\n\n**Params**\n\n* `locals` **{Object}**: Optionally pass locals to the engine.\n* `returns` **{Object}** `View`: instance, for chaining.\n\n**Example**\n\n```js\nvar view = new View({content: 'This is <%= title %>'});\nview.renderSync({title: 'Home'});\nconsole.log(view.content);\n```\n\n### [.render](index.js#L101)\n\nAsynchronously render templates in `view.content`.\n\n**Params**\n\n* `locals` **{Object}**: Context to use for rendering templates.\n\n**Example**\n\n```js\nview.render({title: 'Home'}, function(err, res) {\n  //=> view object with rendered `content`\n});\n```\n\n### [.context](index.js#L132)\n\nCreate a context object from `locals` and the `view.data` and `view.locals` objects. The `view.data` property is typically created from front-matter, and `view.locals` is used when a `new View()` is created.\n\nThis method be overridden either by defining a custom `view.options.context` function\nto customize context for a view instance, or static [View.context](#view-context) function to customize\ncontext for all view instances.\n\n**Params**\n\n* `locals` **{Object}**: Optionally pass a locals object to merge onto the context.\n* `returns` **{Object}**: Returns the context object.\n\n**Example**\n\n```js\nvar page = new View({path: 'a/b/c.txt', locals: {a: 'b', c: 'd'}});\nvar ctx = page.context({a: 'z'});\nconsole.log(ctx);\n//=> {a: 'z', c: 'd'}\n```\n\n### [.isType](index.js#L148)\n\nReturns true if the view is the given `viewType`. Returns `false` if no type is assigned. When used with vinyl-collections, types are assigned by their respective collections.\n\n**Params**\n\n* `type` **{String}**: (`renderable`, `partial`, `layout`)\n\n**Example**\n\n```js\nvar view = new View({path: 'a/b/c.txt', viewType: 'partial'})\nview.isType('partial');\n```\n\n### [.View.context](index.js#L248)\n\nDefine a custom static `View.context` function to override default `.context` behavior. See the [context](#context) docs for more info.\n\n**Params**\n\n* `locals` **{Object}**\n* `returns` **{Object}**\n\n**Example**\n\n```js\n// custom context function\nView.context = function(locals) {\n  // `this` is the view being rendered\n  return locals;\n};\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Building docs\n\n_(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.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n### Running tests\n\nRunning 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:\n\n```sh\n$ npm install && npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nMIT\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 08, 2017._","publish_time":1486597188228,"_cnpm_publish_time":1486597188228,"dist-tags":{"latest":"2.0.1"}}