templates
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -49,4 +49,4 @@ /*! | ||
} | ||
this.options = options || {}; | ||
Base.call(this); | ||
this.options = options || {}; | ||
this.defaultConfig(); | ||
@@ -53,0 +53,0 @@ } |
@@ -28,4 +28,5 @@ 'use strict'; | ||
} | ||
this.options = options || {}; | ||
Base.call(this); | ||
this.init(options || {}); | ||
this.init(this.options); | ||
} | ||
@@ -32,0 +33,0 @@ |
@@ -33,2 +33,10 @@ 'use strict'; | ||
/** | ||
* Register a default data loader | ||
*/ | ||
app.dataLoader('json', function (str) { | ||
return JSON.parse(str); | ||
}); | ||
/** | ||
* Build the context for the given `view` and `locals`. | ||
@@ -35,0 +43,0 @@ * |
'use strict'; | ||
var utils = require('../utils'); | ||
var Base = require('../base'); | ||
@@ -5,0 +6,0 @@ /** |
'use strict'; | ||
var option = require('./option'); | ||
var utils = require('../utils'); | ||
var Base = require('../base'); | ||
@@ -14,3 +14,3 @@ /** | ||
if (typeof view.option !== 'function') { | ||
option(view); | ||
utils.option.call(view, view); | ||
utils.defaults(view.options, options); | ||
@@ -47,2 +47,7 @@ } | ||
exports.all = function (app, view, options) { | ||
if (!view.isItem && !view.isView) { | ||
for (var key in Base.prototype) { | ||
view[key] = Base.prototype[key]; | ||
} | ||
} | ||
exports.option(app, view, options); | ||
@@ -49,0 +54,0 @@ exports.compile(app, view); |
@@ -19,2 +19,3 @@ 'use strict'; | ||
require('base-data', 'data'); | ||
require('base-options', 'option'); | ||
require('array-sort', 'sortBy'); | ||
@@ -21,0 +22,0 @@ require('group-array', 'groupBy'); |
@@ -227,3 +227,3 @@ 'use strict'; | ||
Views.prototype.extendView = function(view) { | ||
plugin.view.all(this, view); | ||
return plugin.view.all(this, view); | ||
}; | ||
@@ -230,0 +230,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.6", | ||
"version": "0.3.7", | ||
"homepage": "https://github.com/jonschlinkert/templates", | ||
@@ -26,6 +26,6 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"array-sort": "^0.1.1", | ||
"base-data": "^0.2.0", | ||
"base-data": "^0.3.0", | ||
"base-methods": "^0.2.14", | ||
"base-options": "^0.3.0", | ||
"base-plugins": "^0.2.0", | ||
"base-plugins": "^0.2.1", | ||
"clone": "^1.0.2", | ||
@@ -32,0 +32,0 @@ "clone-stats": "0.0.1", |
200
README.md
@@ -47,20 +47,14 @@ # templates [](http://badge.fury.io/js/templates) [](https://travis-ci.org/jonschlinkert/templates) [](https://coveralls.io/r/jonschlinkert/templates) | ||
- [Application](#application) | ||
- [Settings](#settings) | ||
- [Engines](#engines) | ||
- [Helpers](#helpers) | ||
- [View](#view) | ||
+ [Settings](#settings) | ||
+ [Data](#data) | ||
+ [data](#data) | ||
- [Item](#item) | ||
+ [Settings](#settings) | ||
+ [Data](#data) | ||
+ [data](#data) | ||
- [Collections](#collections) | ||
+ [Settings](#settings) | ||
+ [Data](#data) | ||
- [List](#list) | ||
+ [Settings](#settings) | ||
- [Group](#group) | ||
@@ -177,4 +171,24 @@ - [Lookups](#lookups) | ||
### [.collection](index.js#L149) | ||
### [.list](index.js#L152) | ||
Create a new list. See the [list docs](docs/lists.md) for more information about lists. | ||
**Params** | ||
* `opts` **{Object}**: List options | ||
* `returns` **{Object}**: Returns the `list` instance for chaining. | ||
**Example** | ||
```js | ||
var list = app.list(); | ||
list.addItem('abc', {content: '...'}); | ||
// or, create list from a collection | ||
app.create('pages'); | ||
var list = app.list(app.pages); | ||
``` | ||
### [.collection](index.js#L192) | ||
Create a new collection. Collections are decorated with special methods for getting and setting items from the collection. Note that, unlike the [create](#create) method, collections created with `.collection()` are not cached. | ||
@@ -190,3 +204,3 @@ | ||
### [.create](index.js#L188) | ||
### [.create](index.js#L230) | ||
@@ -202,23 +216,2 @@ Create a new view collection to be stored on the `app.views` object. See | ||
### Settings | ||
### [.option](lib/plugins/option.js#L24) | ||
Set or get an option value. | ||
**Params** | ||
* `key` **{String|Object}**: Pass a key-value pair or an object to set. | ||
* `val` **{any}**: Any value when a key-value pair is passed. This can also be options if a glob pattern is passed as the first value. | ||
* `returns` **{Object}**: Returns an instance of `Templates` for chaining. | ||
**Example** | ||
```js | ||
app.option('a', 'b'); | ||
app.option({c: 'd'}); | ||
console.log(app.options); | ||
//=> {a: 'b', c: 'd'} | ||
``` | ||
*** | ||
@@ -406,25 +399,4 @@ | ||
#### Settings | ||
#### data | ||
### [.option](lib/plugins/option.js#L24) | ||
Set or get an option value. | ||
**Params** | ||
* `key` **{String|Object}**: Pass a key-value pair or an object to set. | ||
* `val` **{any}**: Any value when a key-value pair is passed. This can also be options if a glob pattern is passed as the first value. | ||
* `returns` **{Object}**: Returns an instance of `Templates` for chaining. | ||
**Example** | ||
```js | ||
view.option('a', 'b'); | ||
view.option({c: 'd'}); | ||
console.log(view.options); | ||
//=> {a: 'b', c: 'd'} | ||
``` | ||
#### Data | ||
### [.data](lib/plugins/context.js#L30) | ||
@@ -449,3 +421,3 @@ | ||
### [.mergePartials](lib/plugins/context.js#L100) | ||
### [.mergePartials](lib/plugins/context.js#L108) | ||
@@ -499,25 +471,4 @@ Merge "partials" view types. This is necessary for template | ||
#### Settings | ||
#### data | ||
### [.option](lib/plugins/option.js#L24) | ||
Set or get an option value. | ||
**Params** | ||
* `key` **{String|Object}**: Pass a key-value pair or an object to set. | ||
* `val` **{any}**: Any value when a key-value pair is passed. This can also be options if a glob pattern is passed as the first value. | ||
* `returns` **{Object}**: Returns an instance of `Templates` for chaining. | ||
**Example** | ||
```js | ||
item.option('a', 'b'); | ||
item.option({c: 'd'}); | ||
console.log(item.options); | ||
//=> {a: 'b', c: 'd'} | ||
``` | ||
#### Data | ||
### [.data](lib/plugins/context.js#L30) | ||
@@ -542,3 +493,3 @@ | ||
### [.mergePartials](lib/plugins/context.js#L100) | ||
### [.mergePartials](lib/plugins/context.js#L108) | ||
@@ -591,3 +542,3 @@ Merge "partials" view types. This is necessary for template | ||
### [.addItem](lib/collection.js#L107) | ||
### [.addItem](lib/collection.js#L108) | ||
@@ -608,3 +559,3 @@ Similar to `setItem`, adds an item to the collection but also fires an event and iterates over the item `queue` to load items from the `addItem` event listener. An item may be an instance of `Item`, if not, the item is converted to an instance of `Item`. | ||
### [.addItems](lib/collection.js#L133) | ||
### [.addItems](lib/collection.js#L134) | ||
@@ -628,3 +579,3 @@ Load multiple items onto the collection. | ||
### [.addList](lib/collection.js#L160) | ||
### [.addList](lib/collection.js#L161) | ||
@@ -649,3 +600,3 @@ Load an array of items onto the collection. | ||
### [.getItem](lib/collection.js#L191) | ||
### [.getItem](lib/collection.js#L192) | ||
@@ -665,23 +616,2 @@ Get an item from the collection. | ||
#### Settings | ||
### [.option](lib/plugins/option.js#L24) | ||
Set or get an option value. | ||
**Params** | ||
* `key` **{String|Object}**: Pass a key-value pair or an object to set. | ||
* `val` **{any}**: Any value when a key-value pair is passed. This can also be options if a glob pattern is passed as the first value. | ||
* `returns` **{Object}**: Returns an instance of `Templates` for chaining. | ||
**Example** | ||
```js | ||
collection.option('a', 'b'); | ||
collection.option({c: 'd'}); | ||
console.log(collection.options); | ||
//=> {a: 'b', c: 'd'} | ||
``` | ||
#### Data | ||
@@ -708,3 +638,3 @@ | ||
### [.mergePartials](lib/plugins/context.js#L100) | ||
### [.mergePartials](lib/plugins/context.js#L108) | ||
@@ -757,3 +687,3 @@ Merge "partials" view types. This is necessary for template | ||
### [.addItem](lib/list.js#L134) | ||
### [.addItem](lib/list.js#L136) | ||
@@ -775,3 +705,3 @@ Similar to [setItem](#setItem), adds an item to the list but also fires an event and iterates over the item `queue` to load items from the `addItem` event listener. If the given item is not already an instance of `Item`, it will be converted to one before being added to the `items` object. | ||
### [.addItems](lib/list.js#L161) | ||
### [.addItems](lib/list.js#L163) | ||
@@ -795,3 +725,3 @@ Load multiple items onto the collection. | ||
### [.addList](lib/list.js#L190) | ||
### [.addList](lib/list.js#L192) | ||
@@ -814,4 +744,21 @@ Load an array of items or the items from another instance of `List`. | ||
### [.getIndex](lib/list.js#L226) | ||
### [.hasItem](lib/list.js#L229) | ||
Return true if the list has the given item (name). | ||
**Params** | ||
* `key` **{String}** | ||
* `returns` **{Object}** | ||
**Example** | ||
```js | ||
list.addItem('foo.html', {content: '...'}); | ||
list.hasItem('foo.html'); | ||
//=> true | ||
``` | ||
### [.getIndex](lib/list.js#L245) | ||
Get a the index of a specific item from the list by `key`. | ||
@@ -831,3 +778,3 @@ | ||
### [.getItem](lib/list.js#L242) | ||
### [.getItem](lib/list.js#L261) | ||
@@ -848,3 +795,3 @@ Get a specific item from the list by `key`. | ||
### [.removeItem](lib/list.js#L259) | ||
### [.removeItem](lib/list.js#L278) | ||
@@ -866,3 +813,3 @@ Remove an item from the list. | ||
### [.extendItem](lib/list.js#L279) | ||
### [.extendItem](lib/list.js#L298) | ||
@@ -878,3 +825,3 @@ Decorate each item on the list with additional methods | ||
### [.groupBy](lib/list.js#L297) | ||
### [.groupBy](lib/list.js#L316) | ||
@@ -893,3 +840,3 @@ 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. | ||
### [.sortBy](lib/list.js#L323) | ||
### [.sortBy](lib/list.js#L342) | ||
@@ -909,3 +856,3 @@ 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. | ||
### [.paginate](lib/list.js#L357) | ||
### [.paginate](lib/list.js#L376) | ||
@@ -923,23 +870,2 @@ 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. | ||
#### Settings | ||
### [.option](lib/plugins/option.js#L24) | ||
Set or get an option value. | ||
**Params** | ||
* `key` **{String|Object}**: Pass a key-value pair or an object to set. | ||
* `val` **{any}**: Any value when a key-value pair is passed. This can also be options if a glob pattern is passed as the first value. | ||
* `returns` **{Object}**: Returns an instance of `Templates` for chaining. | ||
**Example** | ||
```js | ||
list.option('a', 'b'); | ||
list.option({c: 'd'}); | ||
console.log(list.options); | ||
//=> {a: 'b', c: 'd'} | ||
``` | ||
*** | ||
@@ -1102,3 +1028,3 @@ | ||
### [.mergePartials](lib/plugins/context.js#L100) | ||
### [.mergePartials](lib/plugins/context.js#L108) | ||
@@ -1223,3 +1149,3 @@ Merge "partials" view types. This is necessary for template | ||
As of October 10, 2015, code coverage is 100%. | ||
As of October 19, 2015, code coverage is 100%. | ||
@@ -1253,2 +1179,2 @@ ```sh | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 10, 2015._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 19, 2015._ |
106763
37
2851
1152
+ Addedbase-data@0.3.7(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedget-intrinsic@1.3.0(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedset-value@0.3.30.4.3(transitive)
+ Addedto-object-path@0.2.0(transitive)
+ Addedunion-value@0.2.4(transitive)
- Removedbase-data@0.2.2(transitive)
- Removedhas-value@0.2.1(transitive)
- Removedsplit-string@1.0.1(transitive)
Updatedbase-data@^0.3.0
Updatedbase-plugins@^0.2.1