Manage context for templates.
npm
Install withnpm i context-manager --save
Usage
var context = ;
API
Context
Create an instance of Context
.
.setContext
Add a context level, optionally passing a value to start with.
name
{String}: The name of the context to add.level
{Number}: Numerical value representing the order in which this level should be merged versus other lvl.value
{Object}: Optionally pass an object to start with.
context;
.getContext
Get the raw (un-merged) context for name
.
name
{String}: The context to get.returns
: {*}
context;context;// => {a: 'b'}
.extendContext
Extend context name
with the given value
name
{String}key
{String}value
{Object}returns
: {String}
context;
.setLevel
Set the level for a context. This determines the order in which the context will be merged when .calculate()
is called.
name
{String}: The name of the context.level
{Number}: The level (number) to set for the level.
if foo context; else context;
.calculate
Calculate the context, optionally passing a callback fn
for sorting. (Note that sorting must be done on levels, not on the context names).
keys
{String|Array}: Key, or array of keys for context levels to include.fn
{Function}: Sort function for determining the order of merging.
app;
.resetContexts
Clear all contexts.
Author
Jon Schlinkert
License
Copyright (c) 2015 Jon Schlinkert
Released under the license
This file was generated by verb on February 21, 2015.