templates
Advanced tools
Comparing version 0.24.2 to 0.24.3
@@ -189,2 +189,6 @@ 'use strict'; | ||
if (typeof view.engineStack === 'undefined') { | ||
utils.define(view, 'engineStack', {}); | ||
} | ||
locals = utils.extend({settings: {}}, locals); | ||
@@ -276,2 +280,6 @@ var ctx = this.context(view, locals); | ||
if (typeof view.localsStack === 'undefined') { | ||
utils.define(view, 'localsStack', []); | ||
} | ||
var ctx = cacheContext(this, view, locals); | ||
@@ -343,3 +351,3 @@ var app = this; | ||
} else if (typeof file.context === 'function') { | ||
return file.context(context); | ||
return file.context(app.cache.data, context); | ||
} else { | ||
@@ -346,0 +354,0 @@ return context; |
@@ -46,3 +46,3 @@ 'use strict'; | ||
var singularName = views.options.inflection; | ||
if (singularName) { | ||
if (singularName && app.isApp) { | ||
views.on(singularName, function() { | ||
@@ -49,0 +49,0 @@ app.emit.bind(app, singularName).apply(app, arguments); |
{ | ||
"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.24.2", | ||
"version": "0.24.3", | ||
"homepage": "https://github.com/jonschlinkert/templates", | ||
@@ -59,3 +59,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"vinyl-item": "^0.1.0", | ||
"vinyl-view": "^0.1.0" | ||
"vinyl-view": "^0.1.2" | ||
}, | ||
@@ -66,3 +66,2 @@ "devDependencies": { | ||
"base-test-suite": "^0.1.12", | ||
"ent": "^2.2.0", | ||
"gulp": "^3.9.1", | ||
@@ -74,3 +73,2 @@ "gulp-eslint": "^3.0.0", | ||
"gulp-unused": "^0.1.2", | ||
"remarkable": "^1.6.2", | ||
"verb-generate-readme": "^0.1.21", | ||
@@ -95,3 +93,4 @@ "yargs-parser": "^2.4.0" | ||
"ignore": [ | ||
"coverage" | ||
"coverage", | ||
"examples/*" | ||
] | ||
@@ -119,3 +118,2 @@ }, | ||
"array-sort", | ||
"assemble", | ||
"base", | ||
@@ -126,8 +124,11 @@ "base-data", | ||
"base-routes", | ||
"engine-handlebars", | ||
"engine-lodash", | ||
"engine-nunjucks", | ||
"assemble-permalinks", | ||
"engine-cache", | ||
"group-array", | ||
"paginationator", | ||
"route-api", | ||
"verb", | ||
"verb-readme-generator", | ||
"verb-generate-readme", | ||
"vinyl", | ||
@@ -134,0 +135,0 @@ "vinyl-item", |
126
README.md
@@ -5,6 +5,8 @@ # templates [![NPM version](https://img.shields.io/npm/v/templates.svg?style=flat)](https://www.npmjs.com/package/templates) [![NPM downloads](https://img.shields.io/npm/dm/templates.svg?style=flat)](https://npmjs.org/package/templates) [![Build Status](https://img.shields.io/travis/jonschlinkert/templates.svg?style=flat)](https://travis-ci.org/jonschlinkert/templates) | ||
## TOC | ||
## Table of Contents | ||
- [Install](#install) | ||
- [Features](#features) | ||
- [Usage](#usage) | ||
* [Example](#example) | ||
- [API](#api) | ||
@@ -31,11 +33,13 @@ * [Common](#common) | ||
* [Context](#context) | ||
* [Routes and middleware](#routes-and-middleware) | ||
* [Middleware](#middleware) | ||
* [is](#is) | ||
- [More examples](#more-examples) | ||
- [History](#history) | ||
- [Related projects](#related-projects) | ||
- [Contributing](#contributing) | ||
- [Building docs](#building-docs) | ||
- [Running tests](#running-tests) | ||
- [Author](#author) | ||
- [License](#license) | ||
- [About](#about) | ||
* [Related projects](#related-projects) | ||
* [Contributing](#contributing) | ||
* [Building docs](#building-docs) | ||
* [Running tests](#running-tests) | ||
* [Author](#author) | ||
* [License](#license) | ||
@@ -52,39 +56,43 @@ _(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_ | ||
**Features** | ||
## Features | ||
* create custom [view collections](#collections) | ||
* register any [template engine](#engine) for rendering views | ||
* register [helpers](#helper) | ||
* partials | ||
* templates are [vinyl](http://github.com/gulpjs/vinyl) files | ||
* rich plugin support, use any [base](https://github.com/node-base/base) plugin! | ||
* render templates with any [template engine](#engine), including [nunjucks](https://github.com/jonschlinkert/engine-nunjucks), [handlebars](https://github.com/jonschlinkert/engine-handlebars), [lodash](https://github.com/jonschlinkert/engine-lodash) and any consolidate engine! | ||
* [helpers](#helpers): support for sync and async | ||
* [templates collections](#collections) support | ||
* partials and includes | ||
* layouts | ||
* plugins | ||
* middleware | ||
* pages | ||
* custom template "types" | ||
* pagination | ||
* [permalinks](https://github.com/assemble/assemble-permalinks) | ||
* [middleware](#middleware) can be used to tranform files at any stage in the render cycle | ||
* pagination | ||
* Much more! | ||
**Example** | ||
## Usage | ||
This is just a very small glimpse at the `templates` API! | ||
```js | ||
var templates = require('templates'); | ||
var app = templates(); | ||
``` | ||
// create a collection | ||
app.create('pages'); | ||
### Example | ||
// add views to the collection | ||
app.page('a.html', {content: 'this is <%= foo %>'}); | ||
app.page('b.html', {content: 'this is <%= bar %>'}); | ||
app.page('c.html', {content: 'this is <%= baz %>'}); | ||
```js | ||
// register an engine to automatically render `md` files | ||
app.engine('md', require('engine-lodash')); | ||
app.pages.getView('a.html') | ||
.render({foo: 'home'}, function (err, view) { | ||
//=> 'this is home' | ||
}); | ||
``` | ||
// create a template collection | ||
app.create('pages'); | ||
## Usage | ||
// add a template to the collection | ||
app.page('post.md', {content: 'This is the <%= title %> page'}); | ||
```js | ||
var templates = require('templates'); | ||
var app = templates(); | ||
// render it | ||
app.render('post.md', {title: 'Home'}, function(err, view) { | ||
console.log(view.content); | ||
//=> 'This is the Home page' | ||
}); | ||
``` | ||
@@ -1719,4 +1727,6 @@ | ||
### Routes and middleware | ||
### Middleware | ||
Control the entire render cycle, with simple-to-use routes and middleware. | ||
**Example** | ||
@@ -2040,2 +2050,24 @@ | ||
## More examples | ||
This is just a very basic glimpse at the `templates` API! | ||
```js | ||
var templates = require('templates'); | ||
var app = templates(); | ||
// create a collection | ||
app.create('pages'); | ||
// add views to the collection | ||
app.page('a.html', {content: 'this is <%= foo %>'}); | ||
app.page('b.html', {content: 'this is <%= bar %>'}); | ||
app.page('c.html', {content: 'this is <%= baz %>'}); | ||
app.pages.getView('a.html') | ||
.render({foo: 'home'}, function (err, view) { | ||
//=> 'this is home' | ||
}); | ||
``` | ||
## History | ||
@@ -2175,5 +2207,5 @@ | ||
## Related projects | ||
## About | ||
You might also be interested in these projects: | ||
### Related projects | ||
@@ -2186,21 +2218,17 @@ * [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") | ||
## Contributing | ||
### Contributing | ||
This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit directly. Any changes to the readme must be made in [.verb.md](.verb.md). See [Building Docs](#building-docs). | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
Or visit the [verb-readme-generator](https://github.com/verbose/verb-readme-generator) project to submit bug reports or pull requests for the readme layout template. | ||
### Building docs | ||
## 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).)_ | ||
_(This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (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): | ||
Generate readme and API documentation with [verb](https://github.com/verbose/verb): | ||
```sh | ||
$ npm install -g verb verb-readme-generator && verb | ||
$ npm install -g verb verb-generate-readme && verb | ||
``` | ||
## Running tests | ||
### Running tests | ||
@@ -2213,3 +2241,3 @@ Install dev dependencies: | ||
## Author | ||
### Author | ||
@@ -2221,3 +2249,3 @@ **Jon Schlinkert** | ||
## License | ||
### License | ||
@@ -2229,2 +2257,2 @@ Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 11, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 23, 2016._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166534
11
3319
2248
Updatedvinyl-view@^0.1.2