templates
Advanced tools
Comparing version 0.3.5 to 0.3.6
46
index.js
@@ -77,2 +77,3 @@ /*! | ||
this.is('App'); | ||
this.plugins = []; | ||
@@ -136,2 +137,45 @@ this.use(plugin.init); | ||
/** | ||
* Create a new list. See the [list docs](docs/lists.md) for more | ||
* information about lists. | ||
* | ||
* ```js | ||
* var list = app.list(); | ||
* list.addItem('abc', {content: '...'}); | ||
* | ||
* // or, create list from a collection | ||
* app.create('pages'); | ||
* var list = app.list(app.pages); | ||
* ``` | ||
* @param {Object} `opts` List options | ||
* @return {Object} Returns the `list` instance for chaining. | ||
* @api public | ||
*/ | ||
Templates.prototype.list = function (opts) { | ||
opts = opts || {}; | ||
if (!opts.isList) { | ||
utils.defaults(opts, this.options); | ||
} | ||
var List = opts.List || this.get('List'); | ||
var list = {}; | ||
if (opts.isList === true) { | ||
list = opts; | ||
} else { | ||
opts.Item = opts.Item || opts.Item || this.get('Item'); | ||
list = new List(opts); | ||
} | ||
// customize list items | ||
this.extendViews(list, opts); | ||
// emit the list | ||
this.emit('list', list, opts); | ||
return list; | ||
}; | ||
/** | ||
* Create a new collection. Collections are decorated with | ||
@@ -145,3 +189,2 @@ * special methods for getting and setting items from the | ||
* | ||
* @name .collection | ||
* @param {Object} `opts` Collection options | ||
@@ -183,3 +226,2 @@ * @return {Object} Returns the `collection` instance for chaining. | ||
* | ||
* @name .create | ||
* @param {String} `name` The name of the collection to create. Plural or singular form may be used, as the inflections are automatically resolved when the collection | ||
@@ -186,0 +228,0 @@ * is created. |
@@ -217,2 +217,19 @@ 'use strict'; | ||
/** | ||
* Return true if the list has the given item (name). | ||
* | ||
* ```js | ||
* list.addItem('foo.html', {content: '...'}); | ||
* list.hasItem('foo.html'); | ||
* //=> true | ||
* ``` | ||
* @param {String} `key` | ||
* @return {Object} | ||
* @api public | ||
*/ | ||
List.prototype.hasItem = function(key) { | ||
return this.getIndex(key) !== -1; | ||
}; | ||
/** | ||
* Get a the index of a specific item from the list by `key`. | ||
@@ -219,0 +236,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.3.5", | ||
"version": "0.3.6", | ||
"homepage": "https://github.com/jonschlinkert/templates", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
109043
2858