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

template

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

template - npm Package Compare versions

Comparing version 0.10.2 to 0.11.0

193

index.js

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

var init = require('./lib/middleware/init');
var loaders = require('./lib/loaders');
var debug = require('./lib/debug');

@@ -232,4 +233,4 @@ var utils = require('./lib');

Template.prototype.defaultLoaders = function() {
this.loader('default', require('./lib/loaders').templates(this));
this.loader('helpers', require('./lib/loaders').helpers(this));
this.loader('default', loaders.templates(this));
this.loader('helpers', loaders.helpers(this));
};

@@ -429,5 +430,6 @@

if (Array.isArray(name)) {
name.forEach(function(key) {
this.param(key, fn);
}, this);
var len = name.length, i = 0;
while (len--) {
this.param(name[i++], fn);
}
return this;

@@ -476,7 +478,9 @@ }

var router = this.router;
var len = fns.length, i = 0;
fns.forEach(function (fn) {
while (len--) {
var fn = fns[i++];
// non-Template instance
if (!fn || !fn.handle || !fn.set) {
return router.use(path, fn.bind(this));
router.use(path, fn.bind(this));
}

@@ -486,3 +490,3 @@ debug.routes('use: %s', path);

fn.parent = this;
}, this);
}
return this;

@@ -506,4 +510,8 @@ };

var route = this.router.route(path);
var args = slice(arguments, 1);
var len = arguments.length - 1;
var args = new Array(len);
for (var i = 0; i < len; i++) {
args[i] = arguments[i + 1];
}
route[method].apply(route, args);

@@ -534,3 +542,8 @@ return this;

var route = this.router.route(path);
var args = slice(arguments, 1);
var len = arguments.length - 1;
var args = new Array(len);
for (var i = 0; i < len; i++) {
args[i] = arguments[i + 1];
}
route.all.apply(route, args);

@@ -574,3 +587,4 @@ return this;

var stack = this.mergeLayouts(locals);
return layouts(template.content, layout, stack, locals);
var res = layouts(template.content, layout, stack, locals);
return res.result;
};

@@ -767,5 +781,5 @@

debug.engine('engine %j:', exts);
arrayify(exts).forEach(function(ext) {
this.registerEngine(ext, fn, options);
}.bind(this));
exts = arrayify(exts);
var len = exts.length;
while (len--) this.registerEngine(exts[len], fn, options);
return this;

@@ -935,5 +949,7 @@ };

options = options || {};
options.matchLoader = function () {
return 'helpers';
};
this._.helpers.addHelpers(this.load(helpers, options));

@@ -1066,3 +1082,2 @@ return this;

var partial = self.views[plural][key];
if (!partial) {

@@ -1103,6 +1118,11 @@ // TODO: use actual delimiters in messages

var self = this;
var args = slice(arguments);
var stack = [];
var len = args.length;
var len = arguments.length;
var args = new Array(len);
for (var i = 0; i < len; i++) {
args[i] = arguments[i];
}
// Default method used to handle sync loading when done

@@ -1229,30 +1249,32 @@ var cb = function (err, template) {

forOwn(template, function (value, key) {
value.locals = value.locals || {};
value.options = extend({ subtype: plural }, options, value.options);
value.layout = value.layout || value.locals.layout;
for (var key in template) {
if (template.hasOwnProperty(key)) {
var value = template[key];
// Add a render method to the template
// TODO: allow additional opts to be passed
// this engine logic is temporary until we decide
// how we want to allow users to control this.
// for now, this allows the user to change the engine
// preference in the the `getExt()` method.
if (utils.hasOwn(opts, 'engine')) {
var ext = opts.engine;
if (ext[0] !== '.') {
ext = '.' + ext;
value.locals = value.locals || {};
value.options = extend({ subtype: plural }, options, value.options);
value.layout = value.layout || value.locals.layout;
// Add a render method to the template TODO: allow additional
// opts to be passed this engine logic is temporary until we
// decide how we want to allow users to control this. for now,
// this allows the user to change the engine preference in the
// the `getExt()` method.
if (utils.hasOwn(opts, 'engine')) {
var ext = opts.engine;
if (ext[0] !== '.') {
ext = '.' + ext;
}
value.options._engine = ext;
}
value.options._engine = ext;
if (utils.hasOwn(opts, 'delims')) {
value.options.delims = opts.delims;
}
value.render = function (locals, cb) {
return self.renderTemplate(this, locals, cb);
};
template[key] = value;
}
if (utils.hasOwn(opts, 'delims')) {
value.options.delims = opts.delims;
}
value.render = function (locals, cb) {
return self.renderTemplate(this, locals, cb);
};
template[key] = value;
}, this);
}
return template;

@@ -1358,7 +1380,10 @@ };

var arr = this.type[type];
var len = arr.length, i = 0;
var res = {};
return arr.reduce(function(acc, plural) {
acc[plural] = this.views[plural];
return acc;
}.bind(this), {});
while (len--) {
var plural = arr[i++];
res[plural] = this.views[plural];
}
return res;
};

@@ -1384,15 +1409,13 @@

collections = arrayify(collections || Object.keys(obj));
var len = collections.length;
var o = {};
var i = len - 1;
var len = collections.length, res = {};
while (len--) {
var colection = collections[i--];
var colection = collections[len];
for (var key in this.views[colection]) {
if (utils.hasOwn(this.views[colection], key)) {
o[key] = this.views[colection][key];
res[key] = this.views[colection][key];
}
}
}
return o;
return res;
};

@@ -1428,6 +1451,10 @@

}
var mergeTypeContext = this.mergeTypeContext.bind(this, 'layouts');
forOwn(layouts, function (value, key) {
mergeTypeContext(key, value.locals, value.data);
});
for (var key in layouts) {
if (layouts.hasOwnProperty(key)) {
var value = layouts[key];
mergeTypeContext(key, value.locals, value.data);
}
}
return layouts;

@@ -1468,5 +1495,8 @@ };

var arr = this.type.partial;
var len = arr.length, i = 0;
// loop over each `partial` collection (e.g. `docs`)
this.type.partial.forEach(function (plural) {
while (len--) {
var plural = arr[i++];
// Example `this.views.docs`

@@ -1477,25 +1507,28 @@ var collection = this.views[plural];

// Loop over each partial in the collection
forOwn(collection, function (value, key/*, template*/) {
mergeTypeContext(key, value.locals, value.data);
for (var key in collection) {
if (collection.hasOwnProperty(key)) {
var value = collection[key];
// get the globally stored context that we just created
// using `mergeTypeContext` for the current partial
var layoutOpts = this.cache._context.partials[key];
layoutOpts.layoutDelims = pickFrom('layoutDelims', [layoutOpts, opts]);
mergeTypeContext(key, value.locals, value.data);
// wrap the partial with a layout, if applicable
value.content = this.applyLayout(value, layoutOpts);
// get the globally stored context that we just created
// using `mergeTypeContext` for the current partial
var layoutOpts = this.cache._context.partials[key];
layoutOpts.layoutDelims = pickFrom('layoutDelims', [layoutOpts, opts]);
// If `mergePartials` is true combine all `partial` subtypes
if (mergePartials === true) {
opts.partials[key] = value.content;
// wrap the partial with a layout, if applicable
value.content = this.applyLayout(value, layoutOpts);
// Otherwise, each partial subtype on a separate object
} else {
opts[plural] = opts[plural] || {};
opts[plural][key] = value.content;
// If `mergePartials` is true combine all `partial` subtypes
if (mergePartials === true) {
opts.partials[key] = value.content;
// Otherwise, each partial subtype on a separate object
} else {
opts[plural] = opts[plural] || {};
opts[plural][key] = value.content;
}
}
}, this);
}, this);
}
}
context.options = extend({}, context.options, opts);

@@ -1619,4 +1652,9 @@ return context;

debug.template('creating subtype: %s', subtype);
var args = slice(arguments);
var len = arguments.length;
var args = new Array(len);
for (var i = 0; i < len; i++) {
args[i] = arguments[i];
}
// normalize arguments

@@ -1633,3 +1671,3 @@ if (typeOf(plural) !== 'string') { args.splice(1, 0, subtype + 's'); }

// add loaders to default loaders
this.setLoaders(subtype, opts, slice(args, 3));
this.setLoaders(subtype, opts, args.slice(3));

@@ -2017,3 +2055,2 @@ // Add convenience methods for this sub-type

}
return this.renderString(content, locals, cb);

@@ -2020,0 +2057,0 @@ };

{
"name": "template",
"description": "Render templates from any engine. Make custom template types, use layouts on pages, partials or any custom template type, custom delimiters, helpers, middleware, routes, loaders, and lots more. Powers Assemble v0.6.0, Verb v0.3.0 and your application.",
"version": "0.10.2",
"version": "0.11.0",
"homepage": "https://github.com/jonschlinkert/template",

@@ -35,25 +35,25 @@ "author": {

"dependencies": {
"ansi-styles": "^2.0.0",
"ansi-styles": "^2.0.1",
"arr-flatten": "^1.0.0",
"array-slice": "^0.2.2",
"arrayify-compact": "^0.1.0",
"chalk": "^0.5.1",
"chalk": "^1.0.0",
"clone-deep": "^0.1.1",
"config-cache": "^1.0.1",
"debug": "^2.1.1",
"config-cache": "^1.2.0",
"debug": "^2.1.2",
"delimiters": "^1.0.1",
"en-route": "^0.4.0",
"en-route": "^0.5.0",
"engine-cache": "^0.9.0",
"engine-lodash": "^0.5.0",
"extend-shallow": "^0.2.0",
"extend-shallow": "^1.1.2",
"for-own": "^0.1.2",
"globby": "^1.1.0",
"helper-cache": "^0.5.0",
"globby": "^1.2.0",
"helper-cache": "^0.5.2",
"kind-of": "^1.1.0",
"layouts": "^0.7.1",
"load-templates": "^0.5.3",
"loader-cache": "^0.3.1",
"mixin-deep": "^0.1.0",
"layouts": "^0.8.1",
"load-templates": "^0.6.0",
"loader-cache": "^0.4.0",
"mixin-deep": "^1.0.1",
"object.reduce": "^0.1.3",
"parser-front-matter": "^1.1.0",
"parser-front-matter": "^1.2.0",
"pick-from": "^0.1.0"

@@ -60,0 +60,0 @@ },

@@ -1,2 +0,2 @@

# template [![NPM version](https://badge.fury.io/js/template.svg)](http://badge.fury.io/js/template) [![Coverage Status](https://img.shields.io/coveralls/jonschlinkert/template.svg)](https://coveralls.io/r/jonschlinkert/template)
# template [![NPM version](https://badge.fury.io/js/template.svg)](http://badge.fury.io/js/template) [![Build Status](https://travis-ci.org/jonschlinkert/template.svg)](https://travis-ci.org/jonschlinkert/template) [![Coverage Status](https://img.shields.io/coveralls/jonschlinkert/template.svg)](https://coveralls.io/r/jonschlinkert/template)

@@ -7,3 +7,3 @@ > Render templates from any engine. Make custom template types, use layouts on pages, partials or any custom template type, custom delimiters, helpers, middleware, routes, loaders, and lots more. Powers Assemble v0.6.0, Verb v0.3.0 and your application.

- **100% test coverage** (as of Feb. 13, 2015) with [~500 unit tests](./tests)
- **~100% test coverage** (as of Mar. 10, 2015) with [~500 unit tests](./tests)
- **Render** templates with any engine, including any [consolidate](https://github.com/tj/consolidate.js),

@@ -230,2 +230,15 @@ [transformers](https://github.com/ForbesLindesay/transformers), or any compatible engine. Or, create your own!

## Related
Libraries that are used in Template:
* [layouts](https://github.com/doowb/layouts): Wrap templates with layouts. Layouts can be nested and optionally use other layouts.
* [bluebird](https://github.com/petkaantonov/bluebird): Full featured Promises/A+ implementation with exceptionally good performance
* [async](https://github.com/caolan/async): Higher-order functions and common patterns for asynchronous code
* [config-cache](https://github.com/jonschlinkert/config-cache): General purpose JavaScript object storage methods.
* [en-route](https://github.com/jonschlinkert/en-route): Routing for static site generators, build systems and task runners, heavily based on express.js routes but works with file objects. Used by Assemble, Verb, and Template.
* [engine-cache](https://github.com/jonschlinkert/engine-cache): express.js inspired template-engine manager.
* [helper-cache](https://github.com/jonschlinkert/helper-cache): Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.
* [loader-cache](https://github.com/jonschlinkert/loader-cache): Register loader functions that dynamically read, parse or otherwise transform file contents when the name of the loader matches a file extension. You can also compose loaders from other loaders.
## Build docs

@@ -239,13 +252,14 @@

## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/template/issues)
## Run tests
Install dev dependencies.
Install devDependencies:
```js
npm i -d && verb test
```bash
npm i -d && npm test
```
TBC...
## Authors

@@ -264,3 +278,2 @@

## License

@@ -272,3 +285,3 @@ Copyright (c) 2014-2015 Jon Schlinkert

_This file was generated by [verb](https://github.com/assemble/verb) on February 13, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 10, 2015._

@@ -275,0 +288,0 @@

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