UNPKG

vinyl-item

Version:

Extends vinyl files with properties used in vinyl-collections.

110 lines (69 loc) 4.56 kB
# vinyl-item [![NPM version](https://img.shields.io/npm/v/vinyl-item.svg?style=flat)](https://www.npmjs.com/package/vinyl-item) [![NPM monthly downloads](https://img.shields.io/npm/dm/vinyl-item.svg?style=flat)](https://npmjs.org/package/vinyl-item) [![NPM total downloads](https://img.shields.io/npm/dt/vinyl-item.svg?style=flat)](https://npmjs.org/package/vinyl-item) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/vinyl-item.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/vinyl-item) > Extends vinyl files with properties used in vinyl-collections. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save vinyl-item ``` ## Usage Use the same way you would use a [vinyl](https://github.com/gulpjs/vinyl) file: ```js var Item = require('vinyl-item'); var item = new Item({path: 'foo'}); ``` ## API ### [Item](index.js#L32) Create an instance of `Item`. Optionally pass a default object to use. See [vinyl](https://github.com/gulpjs/vinyl) docs for API details and additional documentation. **Example** ```js var item = new Item({ path: 'foo.html', contents: new Buffer('...') }); ``` **Params** * `item` **{Object}** ### [.content](index.js#L215) Normalize the `content` and `contents` properties on `item`. This is done to ensure compatibility with the vinyl convention of using `contents` as a Buffer, as well as the assemble convention of using `content` as a string. We will eventually deprecate the `content` property. **Example** ```js var item = new Item({path: 'foo/bar.hbs', contents: new Buffer('foo')}); console.log(item.content); //=> 'foo' ``` ### [.engine](index.js#L237) Getter/setter to resolve the name of the `engine` to use for rendering. **Example** ```js var item = new Item({path: 'foo/bar.hbs'}); console.log(item.engine); //=> '.hbs' ``` ## About ### Related projects * [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") * [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine… [more](https://github.com/jonschlinkert/templates) | [homepage](https://github.com/jonschlinkert/templates "System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.") * [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.") * [vinyl](https://www.npmjs.com/package/vinyl): Virtual file format. | [homepage](https://github.com/gulpjs/vinyl#readme "Virtual file format.") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Building docs _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (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).)_ To generate the readme and API documentation with [verb](https://github.com/verbose/verb): ```sh $ npm install -g verb verb-generate-readme && verb ``` ### Running tests Install dev dependencies: ```sh $ npm install -d && npm test ``` ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ### License Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT license](https://github.com/jonschlinkert/vinyl-item/blob/master/LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on December 28, 2016._