Comparing version 0.3.2 to 0.4.0
@@ -18,2 +18,5 @@ --- | ||
## API | ||
**Heads up!** Although most of the examples use `<%= foo %>` syntax for delimiters, you can change these to be whatever you need. | ||
{%= jscomments("index.js") %} | ||
@@ -20,0 +23,0 @@ |
67
index.js
@@ -16,2 +16,3 @@ /*! | ||
var _ = require('lodash'); | ||
var extend = _.extend; | ||
@@ -32,4 +33,4 @@ | ||
* @param {Object} `options` Options to use. | ||
* @param {Array} `options.delims` Template delimiters to use formatted as an array (`['{{', '}}']`) | ||
* @param {String} `options.tag` The tag name to use. Default is `body` (e.g. `{{ body }}`) | ||
* @param {Array} `options.delims` Template delimiters to use formatted as an array (`['<%=, '%>']`) | ||
* @param {String} `options.tag` The tag name to use. Default is `body` (e.g. `<%= body %>`) | ||
*/ | ||
@@ -39,3 +40,3 @@ | ||
Cache.call(this, options); | ||
this.init(options); | ||
this.initLayouts(options); | ||
} | ||
@@ -52,13 +53,13 @@ | ||
Layouts.prototype.init = function (options) { | ||
this.options = _.extend({}, options); | ||
this._extendMethod = this.options.extend || _.extend; | ||
Layouts.prototype.initLayouts = function (options) { | ||
this.options = extend({}, options); | ||
this._mergeFn = this.options.mergeFn || _.merge; | ||
// Create the default `{{ body }}` tag | ||
// Create the default `{%= body %}` tag | ||
this.defaultTag = this.makeTag(this.options); | ||
var o = {}; | ||
_.extend(o, this.options.cache); | ||
_.extend(o, this.options.layouts); | ||
_.extend(o, this.cache.data); | ||
extend(o, this.options.cache); | ||
extend(o, this.options.layouts); | ||
extend(o, this.cache.data); | ||
@@ -71,3 +72,3 @@ // Clean up properties from user options. | ||
// Init the context using any locals pass on `options` | ||
this.context = _.extend({}, this.options.locals); | ||
this.context = extend({}, this.options.locals); | ||
// flatten nested `cache` objects | ||
@@ -83,3 +84,3 @@ this.flattenData(this.cache, 'cache'); | ||
* @param {Object} options | ||
* @return {String} The actual body tag, e.g. `{{ body }}` | ||
* @return {String} The actual body tag, e.g. `<%= body %>` | ||
* @api private | ||
@@ -89,4 +90,4 @@ */ | ||
Layouts.prototype.makeTag = function (options) { | ||
var opts = _.extend({}, this.options, options); | ||
opts.delims = opts.delims || ['{{', '}}']; | ||
var opts = extend({}, this.options, options); | ||
opts.delims = opts.delims || ['{%=', '%}']; | ||
opts.tag = opts.tag || 'body'; | ||
@@ -112,3 +113,3 @@ | ||
Layouts.prototype.makeRegex = function (options) { | ||
var opts = _.extend({sep: '\\s*'}, this.options, options); | ||
var opts = extend({sep: '\\s*'}, this.options, options); | ||
var tag = this.makeTag(opts).replace(/[\]()[{|}]/g, '\\$&'); | ||
@@ -126,3 +127,3 @@ return new RegExp(tag, opts.flags || 'g'); | ||
* ```js | ||
* layouts.setLayout('a', 'b', '<h1>Foo</h1>\n{{body}}\n'); | ||
* layouts.setLayout('a', 'b', '<h1>Foo</h1>\n<%= body %>\n'); | ||
* ``` | ||
@@ -139,3 +140,3 @@ * | ||
if (arguments.length === 1 && typeof name === 'object') { | ||
this.cache = _.extend({}, this.cache, name); | ||
this.cache = extend({}, this.cache, name); | ||
return this; | ||
@@ -149,2 +150,3 @@ } | ||
}; | ||
return this; | ||
@@ -161,3 +163,3 @@ }; | ||
* layouts.getLayout('a'); | ||
* //=> { layout: 'b', content: '<h1>Foo</h1>\n{{body}}\n' } | ||
* //=> { layout: 'b', content: '<h1>Foo</h1>\n<%= body %>\n' } | ||
* ``` | ||
@@ -185,5 +187,5 @@ * | ||
Layouts.prototype._defaultLayout = function (context, options) { | ||
var opts = _.extend({}, options); | ||
var tag = (this.makeTag(options) || this.defaultTag).replace(/\s/g, ''); | ||
var settings = _.extend(delims.templates(options.delims || ['{{','}}']), options); | ||
var opts = extend({}, options); | ||
var tag = (this.makeTag(options) || this.defaultTag); | ||
var settings = extend(delims.templates(options.delims || ['{%=','%}']), options); | ||
@@ -231,3 +233,3 @@ settings.interpolate = settings.evaluate; | ||
Layouts.prototype.createStack = function (name, options) { | ||
var opts = _.extend({}, this.options, options); | ||
var opts = extend({}, this.options, options); | ||
name = this.assertLayout(name, opts.defaultLayout); | ||
@@ -269,3 +271,3 @@ | ||
var stack = this.createStack(name, options); | ||
var opts = _.extend(this.options, options); | ||
var opts = extend(this.options, options); | ||
@@ -325,3 +327,3 @@ var tag = this.makeTag(opts) || this.defaultTag; | ||
var ctx = _.extend({}, context, this.context, { | ||
var ctx = extend({}, context, this.context, { | ||
body: layout.variable | ||
@@ -335,3 +337,3 @@ }); | ||
/** | ||
* Replace a `{{body}}` tag with the given `str`. Custom delimiters | ||
* Replace a `<%= body %>` tag with the given `str`. Custom delimiters | ||
* and/or variable may be passed on the `options`. Unlike `renderLayout`, | ||
@@ -344,3 +346,3 @@ * this method does not render templates, it only peforms a basic regex | ||
* ```js | ||
* layouts.replaceTag('ABC', 'Before {{body}} After'); | ||
* layouts.replaceTag('ABC', 'Before <%= body %> After'); | ||
* //=> 'Before ABC After' | ||
@@ -350,3 +352,3 @@ * ``` | ||
* @param {String} `str` The string to use as a replacement value. | ||
* @param {String} `content` A string with a `{{body}}` tag where the `str` should be injected. | ||
* @param {String} `content` A string with a `<%= body %>` tag where the `str` should be injected. | ||
* @return {String} Resulting flattened content. | ||
@@ -381,3 +383,2 @@ * @api public | ||
var layout = this.stack(name, options); | ||
if (layout.content) { | ||
@@ -391,3 +392,3 @@ str = layout.content.replace(this.regex, str); | ||
/** | ||
* Extend `data` with the given `obj. A custom `_extendMethod` can be | ||
* Extend `data` with the given `obj. A custom `_mergeFn` can be | ||
* passed on `options.extend` to change how data is merged. | ||
@@ -404,4 +405,4 @@ * | ||
// build up the `data` object | ||
_.extend(data, opts, opts.locals, opts.data); | ||
_.extend(data, file, file.data); | ||
extend(data, opts, opts.locals, opts.data); | ||
extend(data, file, file.data); | ||
@@ -412,4 +413,4 @@ // Flatten nested `data` objects | ||
// Extend the context | ||
this._extendMethod(this.context, _.omit(data, [ | ||
'extend', | ||
this._mergeFn(this.context, _.omit(data, [ | ||
'mergeFn', | ||
'content', | ||
@@ -416,0 +417,0 @@ 'delims', |
{ | ||
"name": "layouts", | ||
"description": "Wrap templates with layouts. Layouts can be nested and optionally use other layouts.", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"homepage": "https://github.com/jonschlinkert/layouts", | ||
@@ -79,12 +79,11 @@ "author": { | ||
"should": "^4.0.4", | ||
"verb": ">= 0.2.6", | ||
"verb-tag-jscomments": "^0.2.2" | ||
"verb": ">= 0.2.6" | ||
}, | ||
"dependencies": { | ||
"config-cache": "^0.1.5", | ||
"debug": "^1.0.4", | ||
"delims": "^0.3.0", | ||
"falsey": "^0.1.0", | ||
"lodash": "^2.4.1" | ||
"lodash": "^2.4.1", | ||
"verb-tag-jscomments": "^0.2.2" | ||
} | ||
} |
@@ -19,4 +19,7 @@ # layouts [](http://badge.fury.io/js/layouts) | ||
## API | ||
### [.setLayout](index.js#L128) | ||
**Heads up!** Although most of the examples use `<%= foo %>` syntax for delimiters, you can change these to be whatever you need. | ||
### [.setLayout](index.js#L129) | ||
Store a template on the cache by its `name`, the `layout` to use, and the template's `content. | ||
@@ -31,6 +34,6 @@ | ||
```js | ||
layouts.setLayout('a', 'b', '<h1>Foo</h1>\n{{body}}\n'); | ||
layouts.setLayout('a', 'b', '<h1>Foo</h1>\n<%= body %>\n'); | ||
``` | ||
### [.getLayout](index.js#L158) | ||
### [.getLayout](index.js#L160) | ||
@@ -46,6 +49,6 @@ Get a cached template by `name`. | ||
layouts.getLayout('a'); | ||
//=> { layout: 'b', content: '<h1>Foo</h1>\n{{body}}\n' } | ||
//=> { layout: 'b', content: '<h1>Foo</h1>\n<%= body %>\n' } | ||
``` | ||
### [.stack](index.js#L253) | ||
### [.stack](index.js#L255) | ||
@@ -64,3 +67,3 @@ Reduce a layout stack for a template into a single flattened layout. Pass the `name` of the layout defined for the template (e.g. the first layout in the stack). | ||
### [.renderLayout](index.js#L307) | ||
### [.renderLayout](index.js#L309) | ||
@@ -92,8 +95,8 @@ Render a layout using Lo-Dash, by passing content (`str`), `context` and `options`. | ||
### [.replaceTag](index.js#L337) | ||
### [.replaceTag](index.js#L339) | ||
Replace a `{{body}}` tag with the given `str`. Custom delimiters and/or variable may be passed on the `options`. Unlike `renderLayout`, this method does not render templates, it only peforms a basic regex replacement. | ||
Replace a `<%= body %>` tag with the given `str`. Custom delimiters and/or variable may be passed on the `options`. Unlike `renderLayout`, this method does not render templates, it only peforms a basic regex replacement. | ||
* `str` **{String}**: The string to use as a replacement value. | ||
* `content` **{String}**: A string with a `{{body}}` tag where the `str` should be injected. | ||
* `content` **{String}**: A string with a `<%= body %>` tag where the `str` should be injected. | ||
* `returns` **{String}**: Resulting flattened content. | ||
@@ -104,7 +107,7 @@ | ||
```js | ||
layouts.replaceTag('ABC', 'Before {{body}} After'); | ||
layouts.replaceTag('ABC', 'Before <%= body %> After'); | ||
//=> 'Before ABC After' | ||
``` | ||
### [.render](index.js#L360) | ||
### [.render](index.js#L362) | ||
@@ -137,2 +140,2 @@ Return an object with the string (`str`) and `data` required to build a final layout. This is useful if you need to use your own template engine to handle this final step. | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 29, 2014._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 06, 2014._ |
@@ -19,9 +19,9 @@ /*! | ||
first: { layout: 'a', content: 'I\'m a {{ title }}' }, | ||
a: { layout: 'b', content: 'A above\n{{body}}\nA below' }, | ||
b: { layout: 'c', content: 'B above\n{{body}}\nB below' }, | ||
c: { layout: 'd', content: 'C above\n{{body}}\nC below' }, | ||
d: { layout: 'e', content: 'D above\n{{body}}\nD below' }, | ||
e: { layout: 'f', content: 'E above\n{{body}}\nE below' }, | ||
f: { layout: 'last', content: 'F above\n{{body}}\nF below' }, | ||
last: { layout: undefined, content: 'last!\n{{body}}\nlast!' } | ||
a: { layout: 'b', content: 'A above\n{%= body %}\nA below' }, | ||
b: { layout: 'c', content: 'B above\n{%= body %}\nB below' }, | ||
c: { layout: 'd', content: 'C above\n{%= body %}\nC below' }, | ||
d: { layout: 'e', content: 'D above\n{%= body %}\nD below' }, | ||
e: { layout: 'f', content: 'E above\n{%= body %}\nE below' }, | ||
f: { layout: 'last', content: 'F above\n{%= body %}\nF below' }, | ||
last: { layout: undefined, content: 'last!\n{%= body %}\nlast!' } | ||
} | ||
@@ -36,11 +36,11 @@ }); | ||
layouts.setLayout('first', 'a', 'I\'m a {{ title }}'); | ||
layouts.setLayout('a', 'b', 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{{body}}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('a', 'b', 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{%= body %}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{%= body %}\nlast!'); | ||
Object.keys(layouts.cache).length.should.eql(8); | ||
}); | ||
}); |
@@ -15,10 +15,10 @@ /*! | ||
describe('.data()', function () { | ||
layouts.setLayout('first', 'a', '{{body}}'); | ||
layouts.setLayout('a', {layout: 'b', xyz: 'aaa', one: 'two'}, 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', {layout: 'c', xyz: 'bbb', three: 'four'}, 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{{body}}\nF below'); | ||
layouts.setLayout('last', {xyz: 'zzz'}, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('first', 'a', '{%= body %}'); | ||
layouts.setLayout('a', {layout: 'b', xyz: 'aaa', one: 'two'}, 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', {layout: 'c', xyz: 'bbb', three: 'four'}, 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{%= body %}\nF below'); | ||
layouts.setLayout('last', {xyz: 'zzz'}, 'last!\n{%= body %}\nlast!'); | ||
@@ -35,3 +35,3 @@ it('should return an extended data object from the flattened layouts.', function () { | ||
'A above', | ||
'{{body}}', // should not be compiled | ||
'{%= body %}', // should not be compiled | ||
'A below', | ||
@@ -38,0 +38,0 @@ 'B below', |
@@ -17,9 +17,14 @@ /*! | ||
it('should use default delimiters.', function () { | ||
var actual = layouts.replaceTag('INNER', '{%= body %}[[body]]{%body%}{% body %}<%body%>'); | ||
var expected = 'INNER[[body]]{%body%}{% body %}<%body%>'; | ||
actual.should.eql(expected); | ||
}); | ||
it('should use custom delimiters.', function () { | ||
var actual = layouts.replaceTag('INNER', '{{body}}[[body]]{%body%}{% body %}<%body%>', {delims: ['{%', '%}']}); | ||
var expected = '{{body}}[[body]]INNERINNER<%body%>'; | ||
var actual = layouts.replaceTag('INNER', '{%= body %}[[body]]{%body%}{% body %}<%body%>', {delims: ['{%', '%}']}); | ||
var expected = '{%= body %}[[body]]INNERINNER<%body%>'; | ||
actual.should.eql(expected); | ||
}); | ||
it('should use custom delimiters.', function () { | ||
var actual = layouts.replaceTag('INNER', '{{body}}[[body]]{%body%}{% body %}<%body%>', {delims: ['{{', '}}']}); | ||
var actual = layouts.replaceTag('INNER', '{{ body }}[[body]]{%body%}{% body %}<%body%>', {delims: ['{{', '}}']}); | ||
var expected = 'INNER[[body]]{%body%}{% body %}<%body%>'; | ||
@@ -29,11 +34,11 @@ actual.should.eql(expected); | ||
it('should use custom delimiters.', function () { | ||
var actual = layouts.replaceTag('INNER', '{{body}}[[body]]{%body%}{% body %}<%body%>', {delims: ['[[', ']]']}); | ||
var expected = '{{body}}INNER{%body%}{% body %}<%body%>'; | ||
var actual = layouts.replaceTag('INNER', '{%= body %}[[body]]{%body%}{% body %}<%body%>', {delims: ['[[', ']]']}); | ||
var expected = '{%= body %}INNER{%body%}{% body %}<%body%>'; | ||
actual.should.eql(expected); | ||
}); | ||
it('should use custom delimiters.', function () { | ||
var actual = layouts.replaceTag('INNER', '{{body}}[[body]]{%body%}{% body %}<%body%>', {delims: ['<%', '%>']}); | ||
var expected = '{{body}}[[body]]{%body%}{% body %}INNER'; | ||
var actual = layouts.replaceTag('INNER', '{%= body %}[[body]]{%body%}{% body %}<%body%>', {delims: ['<%', '%>']}); | ||
var expected = '{%= body %}[[body]]{%body%}{% body %}INNER'; | ||
actual.should.eql(expected); | ||
}); | ||
}); |
@@ -57,3 +57,3 @@ /*! | ||
'A above', | ||
'I\'m a Foo', | ||
'I\'m a {{ title }}', | ||
'A below', | ||
@@ -60,0 +60,0 @@ 'B below', |
@@ -17,6 +17,6 @@ /*! | ||
var layouts = new Layouts(); | ||
layouts.setLayout('first', 'a', '{{body}}'); | ||
layouts.setLayout('a', {layout: 'b', xyz: 'aaa', one: 'two'}, 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', {layout: 'last', xyz: 'bbb', three: 'four'}, 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('last', {xyz: 'zzz'}, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('first', 'a', '{%= body %}'); | ||
layouts.setLayout('a', {layout: 'b', xyz: 'aaa', one: 'two'}, 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', {layout: 'last', xyz: 'bbb', three: 'four'}, 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('last', {xyz: 'zzz'}, 'last!\n{%= body %}\nlast!'); | ||
@@ -29,3 +29,3 @@ it('should merge the context so that the inner-most templates context wins.', function () { | ||
'A above', | ||
'{{body}}', | ||
'{%= body %}', | ||
'A below', | ||
@@ -41,7 +41,7 @@ 'B below', | ||
describe('when a custom `extend` function is passed', function () { | ||
var layouts = new Layouts({extend: _.defaults}); | ||
layouts.setLayout('a', {layout: 'b', xyz: 'aaa', one: 'two'}, 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', {layout: 'last', xyz: 'bbb', three: 'four'}, 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('last', {xyz: 'zzz'}, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('first', 'a', '{{body}}'); | ||
var layouts = new Layouts({mergeFn: _.defaults}); | ||
layouts.setLayout('a', {layout: 'b', xyz: 'aaa', one: 'two'}, 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', {layout: 'last', xyz: 'bbb', three: 'four'}, 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('last', {xyz: 'zzz'}, 'last!\n{%= body %}\nlast!'); | ||
layouts.setLayout('first', 'a', '{%= body %}'); | ||
@@ -54,3 +54,3 @@ it('should change the order in which the context is merged.', function () { | ||
'A above', | ||
'{{body}}', | ||
'{%= body %}', | ||
'A below', | ||
@@ -57,0 +57,0 @@ 'B below', |
@@ -18,10 +18,10 @@ /*! | ||
layouts.setLayout({a: { layout: 'b', content: 'A above\n{{body}}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', content: 'B above\n{{body}}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', content: 'C above\n{{body}}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', content: 'D above\n{{body}}\nD below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{{body}}\nlast!' }}); | ||
layouts.setLayout({e: { layout: 'f', content: 'E above\n{{body}}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', content: 'F above\n{{body}}\nF below' }}); | ||
layouts.setLayout({first: { layout: 'a', content: '{{body}}' }}); | ||
layouts.setLayout({a: { layout: 'b', content: 'A above\n{%= body %}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', content: 'B above\n{%= body %}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', content: 'C above\n{%= body %}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', content: 'D above\n{%= body %}\nD below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{%= body %}\nlast!' }}); | ||
layouts.setLayout({e: { layout: 'f', content: 'E above\n{%= body %}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', content: 'F above\n{%= body %}\nF below' }}); | ||
layouts.setLayout({first: { layout: 'a', content: '{%= body %}' }}); | ||
@@ -38,3 +38,3 @@ it('should render content into a layout.', function () { | ||
'A above', | ||
'{{body}}', // last {{body}} tag should be unrendered | ||
'{%= body %}', // last {%= body %} tag should be unrendered | ||
'A below', | ||
@@ -56,12 +56,12 @@ 'B below', | ||
layouts.setLayout('first', 'a', '{{body}}'); | ||
layouts.setLayout('a', 'b', 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', '', 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('last', undefined, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('first', 'a', '{%= body %}'); | ||
layouts.setLayout('a', 'b', 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', '', 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('last', undefined, 'last!\n{%= body %}\nlast!'); | ||
it('should extend the `cache`.', function () { | ||
var actual = layouts.render('Last! {{body}}', 'first'); | ||
var actual = layouts.render('Last! {%= body %}', 'first'); | ||
var expected = [ | ||
@@ -73,3 +73,3 @@ 'E above', | ||
'A above', | ||
'Last! {{body}}', // last {{body}} tag should be unrendered | ||
'Last! {%= body %}', // last {%= body %} tag should be unrendered | ||
'A below', | ||
@@ -76,0 +76,0 @@ 'B below', |
@@ -17,6 +17,6 @@ /*! | ||
layouts.setLayout({first: { layout: 'last', content: '{{body}}' }}); | ||
layouts.setLayout({last: { content: 'LAST above\n{{body}}\nLAST below' }}); | ||
layouts.setLayout({first: { layout: 'last', content: '{%= body %}' }}); | ||
layouts.setLayout({last: { content: 'LAST above\n{%= body %}\nLAST below' }}); | ||
it('should replace the `{{body}}` tag in a layout with the given content.', function () { | ||
it('should replace the `{%= body %}` tag in a layout with the given content.', function () { | ||
var stack = layouts.stack('first'); | ||
@@ -28,4 +28,4 @@ var actual = layouts.replaceTag('aaa bbb ccc', stack.content); | ||
it('should replace the `{{body}}` tag in a layout with the given content.', function () { | ||
var actual = layouts.replaceTag('aaa bbb ccc', 'before\n{{body}}\nafter'); | ||
it('should replace the `{%= body %}` tag in a layout with the given content.', function () { | ||
var actual = layouts.replaceTag('aaa bbb ccc', 'before\n{%= body %}\nafter'); | ||
var expected = 'before\naaa bbb ccc\nafter'; | ||
@@ -35,7 +35,7 @@ actual.should.eql(expected); | ||
it('should leave the "last" `{{body}}` tag if no other layout is defined.', function () { | ||
var actual = layouts.replaceTag('aaa {{body}} ccc', 'before\n{{body}}\nafter'); | ||
var expected = 'before\naaa {{body}} ccc\nafter'; | ||
it('should leave the "last" `{%= body %}` tag if no other layout is defined.', function () { | ||
var actual = layouts.replaceTag('aaa {%= body %} ccc', 'before\n{%= body %}\nafter'); | ||
var expected = 'before\naaa {%= body %} ccc\nafter'; | ||
actual.should.eql(expected); | ||
}); | ||
}); |
@@ -17,9 +17,9 @@ /*! | ||
layouts.setLayout({a: { layout: 'b', content: 'A above\n{{body}}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', content: 'B above\n{{body}}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', content: 'C above\n{{body}}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', content: 'D above\n{{body}}\nD below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{{body}}\nlast!' }}); | ||
layouts.setLayout({e: { layout: 'f', content: 'E above\n{{body}}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', content: 'F above\n{{body}}\nF below' }}); | ||
layouts.setLayout({a: { layout: 'b', content: 'A above\n{%= body %}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', content: 'B above\n{%= body %}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', content: 'C above\n{%= body %}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', content: 'D above\n{%= body %}\nD below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{%= body %}\nlast!' }}); | ||
layouts.setLayout({e: { layout: 'f', content: 'E above\n{%= body %}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', content: 'F above\n{%= body %}\nF below' }}); | ||
layouts.setLayout({first: { title: 'first', layout: 'a', content: 'I\'m a {{ title }}' }}); | ||
@@ -37,3 +37,3 @@ | ||
'A above', | ||
'I\'m a first', | ||
'I\'m a {{ title }}', | ||
'A below', | ||
@@ -55,9 +55,9 @@ 'B below', | ||
layouts.setLayout('first', 'a', 'I\'m a < %= title %>'); | ||
layouts.setLayout('a', 'b', 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{{body}}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('a', 'b', 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{%= body %}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{%= body %}\nlast!'); | ||
@@ -92,9 +92,9 @@ it('should extend the `cache`.', function () { | ||
layouts.setLayout('first', {title: 'first', layout: 'a'}, 'I\'m a {{ title }}'); | ||
layouts.setLayout('a', {layout: 'b'}, 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', {layout: 'c'}, 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', {layout: 'd'}, 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', {layout: 'e'}, 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', {layout: 'f'}, 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('f', {layout: 'last'}, 'F above\n{{body}}\nF below'); | ||
layouts.setLayout('last', {layout: undefined}, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('a', {layout: 'b'}, 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', {layout: 'c'}, 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', {layout: 'd'}, 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', {layout: 'e'}, 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', {layout: 'f'}, 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('f', {layout: 'last'}, 'F above\n{%= body %}\nF below'); | ||
layouts.setLayout('last', {layout: undefined}, 'last!\n{%= body %}\nlast!'); | ||
@@ -111,3 +111,3 @@ it('should extend the `cache` with the layout', function () { | ||
'A above', | ||
'I\'m a first', | ||
'I\'m a {{ title }}', | ||
'A below', | ||
@@ -129,9 +129,9 @@ 'B below', | ||
layouts.setLayout('first', {title: 'first', layout: 'a', content: 'I\'m a {{ title }}'}); | ||
layouts.setLayout('a', {layout: 'b', content: 'A above\n{{body}}\nA below'}); | ||
layouts.setLayout('b', {layout: 'c', content: 'B above\n{{body}}\nB below'}); | ||
layouts.setLayout('c', {layout: 'd', content: 'C above\n{{body}}\nC below'}); | ||
layouts.setLayout('d', {layout: 'e', content: 'D above\n{{body}}\nD below'}); | ||
layouts.setLayout('e', {layout: 'f', content: 'E above\n{{body}}\nE below'}); | ||
layouts.setLayout('f', {layout: 'last', content: 'F above\n{{body}}\nF below'}); | ||
layouts.setLayout('last', {layout: undefined, content: 'last!\n{{body}}\nlast!'}); | ||
layouts.setLayout('a', {layout: 'b', content: 'A above\n{%= body %}\nA below'}); | ||
layouts.setLayout('b', {layout: 'c', content: 'B above\n{%= body %}\nB below'}); | ||
layouts.setLayout('c', {layout: 'd', content: 'C above\n{%= body %}\nC below'}); | ||
layouts.setLayout('d', {layout: 'e', content: 'D above\n{%= body %}\nD below'}); | ||
layouts.setLayout('e', {layout: 'f', content: 'E above\n{%= body %}\nE below'}); | ||
layouts.setLayout('f', {layout: 'last', content: 'F above\n{%= body %}\nF below'}); | ||
layouts.setLayout('last', {layout: undefined, content: 'last!\n{%= body %}\nlast!'}); | ||
@@ -148,3 +148,3 @@ it('should extend the `cache` with the layout', function () { | ||
'A above', | ||
'I\'m a first', | ||
'I\'m a {{ title }}', | ||
'A below', | ||
@@ -166,9 +166,9 @@ 'B below', | ||
layouts.setLayout({ | ||
a: { layout: 'b', content: 'A above\n{{body}}\nA below' }, | ||
b: { layout: 'c', content: 'B above\n{{body}}\nB below' }, | ||
c: { layout: 'd', content: 'C above\n{{body}}\nC below' }, | ||
d: { layout: 'e', content: 'D above\n{{body}}\nD below' }, | ||
last: { layout: undefined, content: 'last!\n{{body}}\nlast!' }, | ||
e: { layout: 'f', content: 'E above\n{{body}}\nE below' }, | ||
f: { layout: 'last', content: 'F above\n{{body}}\nF below' }, | ||
a: { layout: 'b', content: 'A above\n{%= body %}\nA below' }, | ||
b: { layout: 'c', content: 'B above\n{%= body %}\nB below' }, | ||
c: { layout: 'd', content: 'C above\n{%= body %}\nC below' }, | ||
d: { layout: 'e', content: 'D above\n{%= body %}\nD below' }, | ||
last: { layout: undefined, content: 'last!\n{%= body %}\nlast!' }, | ||
e: { layout: 'f', content: 'E above\n{%= body %}\nE below' }, | ||
f: { layout: 'last', content: 'F above\n{%= body %}\nF below' }, | ||
first: { title: 'first', layout: 'a', content: 'I\'m a {{ title }}' } | ||
@@ -187,3 +187,3 @@ }); | ||
'A above', | ||
'I\'m a first', | ||
'I\'m a {{ title }}', | ||
'A below', | ||
@@ -190,0 +190,0 @@ 'B below', |
@@ -18,10 +18,10 @@ /*! | ||
layouts.setLayout({first: { layout: 'a', content: '{{body}}' }}); | ||
layouts.setLayout({a: { layout: 'b', a: 'b', title: 'A', content: '{{ title }} above\n{{body}}\n{{ title }} below' }}); | ||
layouts.setLayout({b: { layout: 'c', c: 'd', title: 'B', content: '{{ title }} above\n{{body}}\n{{ title }} below' }}); | ||
layouts.setLayout({c: { layout: 'd', e: 'f', title: 'C', content: '{{ title }} above\n{{body}}\n{{ title }} below' }}); | ||
layouts.setLayout({d: { layout: 'e', g: 'h', title: 'D', content: '{{ title }} above\n{{body}}\n{{ title }} below' }}); | ||
layouts.setLayout({e: { layout: 'f', i: 'j', title: 'E', content: '{{ title }} above\n{{body}}\n{{ title }} below' }}); | ||
layouts.setLayout({f: { layout: 'last', data: {one: 'two'}, title: 'F', content: '{{ title }} above\n{{body}}\n{{ title }} below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{{body}}\nlast!' }}); | ||
layouts.setLayout({first: { layout: 'a', content: '{%= body %}' }}); | ||
layouts.setLayout({a: { layout: 'b', a: 'b', title: 'A', content: 'A above\n{%= body %}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', c: 'd', title: 'B', content: 'B above\n{%= body %}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', e: 'f', title: 'C', content: 'C above\n{%= body %}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', g: 'h', title: 'D', content: 'D above\n{%= body %}\nD below' }}); | ||
layouts.setLayout({e: { layout: 'f', i: 'j', title: 'E', content: 'E above\n{%= body %}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', data: {one: 'two'}, title: 'F', content: 'F above\n{%= body %}\nF below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{%= body %}\nlast!' }}); | ||
@@ -38,3 +38,3 @@ it('should return a layout stack.', function () { | ||
'A above', | ||
'{{body}}', | ||
'{%= body %}', | ||
'A below', | ||
@@ -68,10 +68,10 @@ 'B below', | ||
layouts.setLayout('first', 'a', '{{body}}'); | ||
layouts.setLayout('a', 'b', 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{{body}}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('first', 'a', '{%= body %}'); | ||
layouts.setLayout('a', 'b', 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{%= body %}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{%= body %}\nlast!'); | ||
@@ -88,3 +88,3 @@ it('should build a layout stack', function () { | ||
'A above', | ||
'{{body}}', | ||
'{%= body %}', | ||
'A below', | ||
@@ -91,0 +91,0 @@ 'B below', |
@@ -18,10 +18,10 @@ /*! | ||
layouts.setLayout({first: { layout: 'a', content: '{{body}}' }}); | ||
layouts.setLayout({a: { layout: 'b', a: 'b', content: 'A above\n{{body}}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', c: 'd', content: 'B above\n{{body}}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', e: 'f', content: 'C above\n{{body}}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', g: 'h', content: 'D above\n{{body}}\nD below' }}); | ||
layouts.setLayout({e: { layout: 'f', i: 'j', content: 'E above\n{{body}}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', data: {one: 'two'}, content: 'F above\n{{body}}\nF below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{{body}}\nlast!' }}); | ||
layouts.setLayout({first: { layout: 'a', content: '{%= body %}' }}); | ||
layouts.setLayout({a: { layout: 'b', a: 'b', content: 'A above\n{%= body %}\nA below' }}); | ||
layouts.setLayout({b: { layout: 'c', c: 'd', content: 'B above\n{%= body %}\nB below' }}); | ||
layouts.setLayout({c: { layout: 'd', e: 'f', content: 'C above\n{%= body %}\nC below' }}); | ||
layouts.setLayout({d: { layout: 'e', g: 'h', content: 'D above\n{%= body %}\nD below' }}); | ||
layouts.setLayout({e: { layout: 'f', i: 'j', content: 'E above\n{%= body %}\nE below' }}); | ||
layouts.setLayout({f: { layout: 'last', data: {one: 'two'}, content: 'F above\n{%= body %}\nF below' }}); | ||
layouts.setLayout({last: { layout: undefined, content: 'last!\n{%= body %}\nlast!' }}); | ||
@@ -38,3 +38,3 @@ it('should return a layout stack.', function () { | ||
'A above', | ||
'{{body}}', | ||
'{%= body %}', | ||
'A below', | ||
@@ -67,10 +67,10 @@ 'B below', | ||
layouts.setLayout('first', 'a', '{{body}}'); | ||
layouts.setLayout('a', 'b', 'A above\n{{body}}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{{body}}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{{body}}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{{body}}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{{body}}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{{body}}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{{body}}\nlast!'); | ||
layouts.setLayout('first', 'a', '{%= body %}'); | ||
layouts.setLayout('a', 'b', 'A above\n{%= body %}\nA below'); | ||
layouts.setLayout('b', 'c', 'B above\n{%= body %}\nB below'); | ||
layouts.setLayout('c', 'd', 'C above\n{%= body %}\nC below'); | ||
layouts.setLayout('d', 'e', 'D above\n{%= body %}\nD below'); | ||
layouts.setLayout('e', 'f', 'E above\n{%= body %}\nE below'); | ||
layouts.setLayout('f', 'last', 'F above\n{%= body %}\nF below'); | ||
layouts.setLayout('last', undefined, 'last!\n{%= body %}\nlast!'); | ||
@@ -87,3 +87,3 @@ it('should build a layout stack', function () { | ||
'A above', | ||
'{{body}}', | ||
'{%= body %}', | ||
'A below', | ||
@@ -90,0 +90,0 @@ 'B below', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46533
5
1094
134
+ Addedverb-tag-jscomments@^0.2.2
+ Addedansi-regex@0.2.1(transitive)
+ Addedansi-styles@1.1.0(transitive)
+ Addedarray-union@1.0.2(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedchalk@0.5.1(transitive)
+ Addedcode-context@0.2.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedextract-comments@0.4.2(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedgfm-code-block-regex@0.2.3(transitive)
+ Addedgfm-code-blocks@0.2.2(transitive)
+ Addedglobby@1.2.0(transitive)
+ Addedhas-ansi@0.1.0(transitive)
+ Addedinflection@1.13.4(transitive)
+ Addedis-plain-object@0.1.0(transitive)
+ Addedjs-comments@0.3.9(transitive)
+ Addedjs-comments-template@0.4.2(transitive)
+ Addedline-count@0.1.0(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedlodash-helpers@0.1.0(transitive)
+ Addedmap-files@0.1.2(transitive)
+ Addedmixin-deep@0.1.0(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedparse-comments@0.3.4(transitive)
+ Addedrelative@1.2.0(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedstrip-ansi@0.3.0(transitive)
+ Addedsupports-color@0.2.0(transitive)
+ Addedverb-tag-jscomments@0.2.2(transitive)
- Removeddebug@^1.0.4
- Removeddebug@1.0.5(transitive)
- Removedms@2.0.0(transitive)