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

templates

Package Overview
Dependencies
Maintainers
3
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templates - npm Package Compare versions

Comparing version 0.1.18 to 0.1.19

2

index.js

@@ -675,2 +675,3 @@ /*!

* ```
* @name .route
* @param {String} `path`

@@ -752,2 +753,3 @@ * @return {Object} `Route` for chaining

* ```
* @name .engine
* @param {String|Array} `exts` String or array of file extensions.

@@ -754,0 +756,0 @@ * @param {Function|Object} `fn` or `settings`

3

lib/list.js

@@ -187,3 +187,3 @@ 'use strict';

/**
* Return an array of pagination objects for each list item.
* Getter for returning an array of pagination objects for each list item.
* Useful when you just want `prev/next` type information.

@@ -205,2 +205,3 @@ *

* ```
* @name .pagination
* @return {Array} Returns the array of pagination pages.

@@ -207,0 +208,0 @@ * @api public

@@ -65,3 +65,3 @@ 'use strict';

*
* ```
* ```js
* var view = new View({path: 'abc', contents: '...'})

@@ -72,4 +72,3 @@ * .use(require('foo'))

* ```
* @name .use
* @param {Function} fn
* @param {Function} `fn`
* @return {Object}

@@ -112,3 +111,2 @@ * @api public

* ```
*
* @param {Object} `locals` Optionally pass locals to the engine.

@@ -144,2 +142,9 @@ * @return {Object} `View` instance, for chaining.

* vinyl's `.clone()` method.
*
* ```js
* view.clone({deep: true}); // false by default
* ```
* @param {Object} `options`
* @return {Object} `view` Cloned instance
* @api public
*/

@@ -207,6 +212,2 @@

View.prototype.extendView = function(fn) {
return this.use(fn);
};
/**

@@ -213,0 +214,0 @@ *

@@ -6,2 +6,13 @@ 'use strict';

/**
* Create an instance of `Views` with the given `options`.
*
* ```js
* var collection = new Views();
* collection.addView('foo', {content: 'bar'});
* ```
* @param {Object} `options`
* @api public
*/
function Views(options) {

@@ -47,4 +58,18 @@ Base.call(this);

*
* ```js
* collection.use(function(views) {
* // `views` is the instance, as is `this`
*
* // optionally return a function to be passed to
* // the `.use` method of each view created on the
* // instance
* return function(view) {
* // do stuff to each `view`
* };
* });
* ```
*
* @param {Function} `fn` Plugin function. If the plugin returns a function it will be passed to the `use` method of each view created on the instance.
* @return {Object} Returns the instance for chaining.
* @api public
*/

@@ -77,4 +102,9 @@

/**
* Uses the `view` method to a view to the collection.
* Set a view on the collection. This is identical to [addView](#addView)
* except `setView` does not emit an event for each view.
*
* ```js
* collection.setView('foo', {content: 'bar'});
* ```
*
* @param {String|Object} `key` View key or object

@@ -94,6 +124,7 @@ * @param {Object} `value` If key is a string, value is the view object.

/**
* Adds event emitting and custom loading to `setView`.
* Adds event emitting and custom loading to [setView](#setView).
*
* @param {String} key
* @param {Object} value
* @param {String} `key`
* @param {Object} `value`
* @api public
*/

@@ -100,0 +131,0 @@

{
"name": "templates",
"description": "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.",
"version": "0.1.18",
"version": "0.1.19",
"homepage": "https://github.com/jonschlinkert/templates",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

@@ -19,3 +19,3 @@ # templates [![NPM version](https://badge.fury.io/js/templates.svg)](http://badge.fury.io/js/templates)

## API
# API

@@ -37,10 +37,10 @@ ### [Templates](index.js#L32)

### [.use](index.js#L140)
### [.use](index.js#L145)
Run a plugin on the instance.
Run a plugin on the instance. Plugins are invoked immediately upon creating the collection in the order in which they were defined.
**Params**
* **{Function}**: fn
* `returns` **{Object}**
* `fn` **{Function}**: Plugin function. If the plugin returns a function it will be passed to the `use` method of each collection created on the instance.
* `returns` **{Object}**: Returns the instance for chaining.

@@ -56,3 +56,3 @@ **Example**

### [.view](index.js#L161)
### [.view](index.js#L169)

@@ -75,3 +75,3 @@ Returns a new view, using the `View` class currently defined on the instance.

### [.data](index.js#L178)
### [.data](index.js#L186)

@@ -93,3 +93,3 @@ Set, get and load data to be passed to templates as context at render-time.

### [.collection](index.js#L220)
### [.collection](index.js#L228)

@@ -117,3 +117,3 @@ Create a new view collection. View collections are decorated with special methods for getting, setting and rendering views from that collection. Collections created with this method are not stored on `app.views` as with the [create](#create) method.

### [.create](index.js#L262)
### [.create](index.js#L273)

@@ -143,3 +143,3 @@ Create a new view collection that is stored on the `app.views` object. For example, if you create a collection named `posts`, then all `posts` will be stored on `app.views.posts`, and a `posts` method will be added to `app`, allowing you to add posts to the collection using `app.posts()`.

### [.find](index.js#L406)
### [.find](index.js#L413)

@@ -163,3 +163,3 @@ Find a view by `name`, optionally passing a `collection` to limit the search. If no collection is passed all `renderable` collections will be searched.

### [.getView](index.js#L444)
### [.getView](index.js#L451)

@@ -186,3 +186,3 @@ Get view `key` from the specified `collection`.

### [.getViews](index.js#L483)
### [.getViews](index.js#L490)

@@ -206,3 +206,3 @@ Get all views from a `collection` using the collection's singular or plural name.

### [.matchView](index.js#L515)
### [.matchView](index.js#L522)

@@ -228,3 +228,3 @@ Returns the first view from `collection` with a key that matches the given glob pattern.

### [.matchViews](index.js#L543)
### [.matchViews](index.js#L550)

@@ -250,3 +250,3 @@ Returns any views from the specified collection with keys that match the given glob pattern.

### [.handle](index.js#L585)
### [.handle](index.js#L592)

@@ -268,2 +268,6 @@ Handle a middleware `method` for `view`.

### [.route](index.js#L681)
Create a new Route for the given path. Each route contains a separate middleware stack.
See the [route API documentation][route-api] for details on

@@ -290,3 +294,3 @@ adding handlers and middleware to routes.

### [.all](index.js#L695)
### [.all](index.js#L703)

@@ -310,3 +314,3 @@ Special route method that works just like the `router.METHOD()` methods, except that it matches all verbs.

### [.param](index.js#L724)
### [.param](index.js#L732)

@@ -335,2 +339,6 @@ Add callback triggers to route parameters, where `name` is the name of the parameter and `fn` is the callback function.

### [.engine](index.js#L759)
Register a view engine callback `fn` as `ext`.
**Params**

@@ -356,3 +364,3 @@

### [.compile](index.js#L882)
### [.compile](index.js#L892)

@@ -382,3 +390,3 @@ Compile `content` with the given `locals`.

### [.render](index.js#L945)
### [.render](index.js#L955)

@@ -402,2 +410,276 @@ Render a view with the given `locals` and `callback`.

## Collections
### [Views](lib/views.js#L17)
Create an instance of `Views` with the given `options`.
**Params**
* `options` **{Object}**
**Example**
```js
var collection = new Views();
collection.addView('foo', {content: 'bar'});
```
### [.use](lib/views.js#L75)
Run a plugin on the collection instance. Plugins are invoked immediately upon creating the collection in the order in which they were defined.
**Params**
* `fn` **{Function}**: Plugin function. If the plugin returns a function it will be passed to the `use` method of each view created on the instance.
* `returns` **{Object}**: Returns the instance for chaining.
**Example**
```js
collection.use(function(views) {
// `views` is the instance, as is `this`
// optionally return a function to be passed to
// the `.use` method of each view created on the
// instance
return function(view) {
// do stuff to each `view`
};
});
```
### [.view](lib/views.js#L99)
Returns a new view, using the `View` class currently defined on the instance.
**Params**
* `key` **{String|Object}**: View key or object
* `value` **{Object}**: If key is a string, value is the view object.
* `returns` **{Object}**: returns the `view` object
**Example**
```js
var view = app.view('foo', {conetent: '...'});
// or
var view = app.view({path: 'foo', conetent: '...'});
```
### [.setView](lib/views.js#L114)
Set a view on the collection. This is identical to [addView](#addView) except `setView` does not emit an event for each view.
**Params**
* `key` **{String|Object}**: View key or object
* `value` **{Object}**: If key is a string, value is the view object.
* `returns` **{Object}**: returns the `view` instance.
**Example**
```js
collection.setView('foo', {content: 'bar'});
```
### [.addView](lib/views.js#L128)
Adds event emitting and custom loading to [setView](#setView).
**Params**
* `key` **{String}**
* `value` **{Object}**
### [.addViews](lib/views.js#L154)
Load multiple views onto the collection.
**Params**
* `views` **{Object|Array}**
* `returns` **{Object}**: returns the `collection` object
**Example**
```js
collection.addViews({
'a.html': {content: '...'},
'b.html': {content: '...'},
'c.html': {content: '...'}
});
```
### [.addList](lib/views.js#L184)
Load an array of views onto the collection.
**Params**
* `views` **{Object|Array}**
* `returns` **{Object}**: returns the `collection` object
**Example**
```js
collection.addViews([
{path: 'a.html', content: '...'},
{path: 'b.html', content: '...'},
{path: 'c.html', content: '...'}
]);
```
### [.getView](lib/views.js#L211)
Get a view from the collection.
**Params**
* `key` **{String}**: Key of the view to get.
* `returns` **{Object}**
**Example**
```js
collection.getView('a.html');
```
## List
### [.groupBy](lib/list.js#L114)
Group all list `items` using the given property, properties or compare functions. See [group-array](https://github.com/doowb/group-array) for the full range of available features and options.
* `returns` **{Object}**: Returns the grouped items.
**Example**
```js
var list = new List();
list.addItems(...);
var groups = list.groupBy('data.date', 'data.slug');
```
### [.sortBy](lib/list.js#L140)
Sort all list `items` using the given property, properties or compare functions. See [array-sort](https://github.com/jonschlinkert/array-sort) for the full range of available features and options.
* `returns` **{Object}**: Returns a new `List` instance with sorted items.
**Example**
```js
var list = new List();
list.addItems(...);
var result = list.sortBy('data.date');
//=> new sorted list
```
### [.paginate](lib/list.js#L174)
Paginate all `items` in the list with the given options, See [paginationator](https://github.com/doowb/paginationator) for the full range of available features and options.
* `returns` **{Object}**: Returns the paginated items.
**Example**
```js
var list = new List(items);
var pages = list.paginate({limit: 5});
```
### [.pagination](lib/list.js#L209)
Getter for returning an array of pagination objects for each list item. Useful when you just want `prev/next` type information.
* `returns` **{Array}**: Returns the array of pagination pages.
**Example**
```js
var list = new List([
{name: 'one'},
{name: 'two'},
{name: 'three'}
]);
var pages = list.pages;
// [
// {idx: 0, current: 1, next: 2, item: {name: 'one'}},
// {idx: 1, current: 2, next: 3, prev: 1, item: {name: 'two'}},
// {idx: 2, current: 3, prev: 2, item: {name: 'three'}}
// ]
```
## View
### [.use](lib/view.js#L76)
Run a plugin on the `view` instance.
**Params**
* `fn` **{Function}**
* `returns` **{Object}**
**Example**
```js
var view = new View({path: 'abc', contents: '...'})
.use(require('foo'))
.use(require('bar'))
.use(require('baz'))
```
### [.compile](lib/view.js#L96)
Synchronously compile a view.
**Params**
* `locals` **{Object}**: Optionally pass locals to the engine.
* `returns` **{Object}** `View`: instance, for chaining.
**Example**
```js
var view = page.compile();
view.fn({title: 'A'});
view.fn({title: 'B'});
view.fn({title: 'C'});
```
### [.render](lib/view.js#L114)
Asynchronously render a view.
**Params**
* `locals` **{Object}**: Optionally pass locals to the engine.
* `returns` **{Object}** `View`: instance, for chaining.
**Example**
```js
view.render({title: 'Home'}, function(err, res) {
//=> view object with rendered `content`
});
```
### [.clone](lib/view.js#L148)
Re-decorate View methods after calling vinyl's `.clone()` method.
**Params**
* `options` **{Object}**
* `returns` **{Object}** `view`: Cloned instance
**Example**
```js
view.clone({deep: true}); // false by default
```
## Related projects

@@ -438,2 +720,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 13, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 16, 2015._
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