Update templates to use dustjs

This commit is contained in:
Timothy Warren 2014-09-18 16:17:29 -04:00
parent adfdc0c938
commit 2adb689553
87 changed files with 11706 additions and 13749 deletions

41
app.js
View File

@ -5,12 +5,12 @@ var logger = require('morgan');
var cookieParser = require('cookie-parser'); var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express(); var app = express();
// view engine setup // view engine setup
var consolidate = require('consolidate');
var dust = require('dustjs-linkedin');
app.engine('dust', consolidate.dust);
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'dust'); app.set('view engine', 'dust');
@ -20,16 +20,19 @@ app.use(logger('dev'));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser()); app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public'), {redirect:false}));
// Route mapping
var routes = require('./routes/index');
var users = require('./routes/users');
app.use('/', routes); app.use('/', routes);
app.use('/users', users); app.use('/users', users);
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function(req, res, next) {
var err = new Error('Not Found'); var err = new Error('Not Found');
err.status = 404; err.status = 404;
next(err); next(err);
}); });
// error handlers // error handlers
@ -37,23 +40,23 @@ app.use(function(req, res, next) {
// development error handler // development error handler
// will print stacktrace // will print stacktrace
if (app.get('env') === 'development') { if (app.get('env') === 'development') {
app.use(function(err, req, res, next) { app.use(function(err, req, res, next) {
res.status(err.status || 500); res.status(err.status || 500);
res.render('error', { res.render('error', {
message: err.message, message: err.message,
error: err error: err
}); });
}); });
} }
// production error handler // production error handler
// no stacktraces leaked to user // no stacktraces leaked to user
app.use(function(err, req, res, next) { app.use(function(err, req, res, next) {
res.status(err.status || 500); res.status(err.status || 500);
res.render('error', { res.render('error', {
message: err.message, message: err.message,
error: {} error: {}
}); });
}); });

1
node_modules/.bin/dustc generated vendored Symbolic link
View File

@ -0,0 +1 @@
../dustjs-linkedin/bin/dustc

4
node_modules/consolidate/.npmignore generated vendored Normal file
View File

@ -0,0 +1,4 @@
support
test
examples
*.sock

86
node_modules/consolidate/History.md generated vendored Normal file
View File

@ -0,0 +1,86 @@
0.10.0 / 2013-11-23
==================
* add lodash support
* add nunjucks support
0.9.1 / 2013-04-29
==================
* Update ECT version
* Added support for Handlebars helpers with test.
* Invalidates built-in dust cache if caching disabled
0.9.0 / 2013-03-28
==================
* dust-helpers support, latest version of dust
* Re-add doT - global leaks fixed
* improving templayed support
0.8.0 / 2013-01-23
==================
* add templayed support
* add `then-jade` as an alternative to `jade`
0.7.0 / 2012-12-28
==================
* add atpl support
0.6.0 2012-12-22
==================
* add partials support
* add support for toffee templates
* remove dot it still leaks and the author has not fixed it
0.5.0 / 2012-10-29
==================
* add `mote` support
* add support to `dust` partials
* add support for `ECT`
* add support for rendering without file
* add support for `JUST`
* improve Haml-Coffee caching.
0.4.0 / 2012-07-30
==================
* add doT support [sannis]
* add mustache support [ForbesLindesay]
* add walrus support [kagd]
0.3.1 / 2012-06-28
==================
* add QEJS support
* add underscore support
* change whiskers to use pre-defined `.__express`
* remove engines. Closes #37
* remove kernel, cannot comply with our caching
0.3.0 / 2012-04-18
==================
* Added partials loading for whiskers [gsf]
* Added dustjs-linkedin support
0.2.0 / 2012-04-04
==================
* Added support for dust [fatjonny]
* Added handlebars support [jstewmon]
0.1.0 / 2012-01-03
==================
* Added support for several more engines
0.0.1 / 2010-01-03
==================
* Initial release

9
node_modules/consolidate/Makefile generated vendored Normal file
View File

@ -0,0 +1,9 @@
REPORTER = spec
test:
@./node_modules/.bin/mocha \
--slow 30 \
--reporter $(REPORTER)
.PHONY: test

155
node_modules/consolidate/Readme.md generated vendored Normal file
View File

@ -0,0 +1,155 @@
# Consolidate.js
Template engine consolidation library.
## Installation
$ npm install consolidate
## Supported template engines
- [atpl](https://github.com/soywiz/atpl.js)
- [dust](https://github.com/akdubya/dustjs) [(website)](http://akdubya.github.com/dustjs/)
- [eco](https://github.com/sstephenson/eco)
- [ect](https://github.com/baryshev/ect) [(website)](http://ectjs.com/)
- [ejs](https://github.com/visionmedia/ejs)
- [haml](https://github.com/visionmedia/haml.js) [(website)](http://haml-lang.com/)
- [haml-coffee](https://github.com/9elements/haml-coffee) [(website)](http://haml-lang.com/)
- [handlebars](https://github.com/wycats/handlebars.js/) [(website)](http://handlebarsjs.com/)
- [hogan](https://github.com/twitter/hogan.js) [(website)](http://twitter.github.com/hogan.js/)
- [jade](https://github.com/visionmedia/jade) [(website)](http://jade-lang.com/)
- [jazz](https://github.com/shinetech/jazz)
- [jqtpl](https://github.com/kof/node-jqtpl) [(website)](http://api.jquery.com/category/plugins/templates/)
- [JUST](https://github.com/baryshev/just)
- [liquor](https://github.com/chjj/liquor)
- [lodash](https://github.com/bestiejs/lodash) [(website)](http://lodash.com/)
- [mustache](https://github.com/janl/mustache.js)
- [QEJS](https://github.com/jepso/QEJS)
- [ractive](https://github.com/Rich-Harris/Ractive)
- [swig](https://github.com/paularmstrong/swig) [(website)](http://paularmstrong.github.com/swig/)
- [templayed](http://archan937.github.com/templayed.js/)
- [toffee](https://github.com/malgorithms/toffee)
- [underscore](https://github.com/documentcloud/underscore) [(website)](http://documentcloud.github.com/underscore/)
- [walrus](https://github.com/jeremyruppel/walrus) [(website)](http://documentup.com/jeremyruppel/walrus/)
- [whiskers](https://github.com/gsf/whiskers.js/tree/)
__NOTE__: you must still install the engines you wish to use, add them to your package.json dependencies.
## API
All templates supported by this library may be rendered using the signature `(path[, locals], callback)` as shown below, which happens to be the signature that Express 3.x supports so any of these engines may be used within Express.
__NOTE__: All this example code uses cons.swig for the swig template engine. Replace swig with whatever templating you are using. For example, use cons.hogan for hogan.js, cons.jade for jade, etc. `console.log(cons)` for the full list of identifiers.
```js
var cons = require('consolidate');
cons.swig('views/page.html', { user: 'tobi' }, function(err, html){
if (err) throw err;
console.log(html);
});
```
Or without options / local variables:
```js
var cons = require('consolidate');
cons.swig('views/page.html', function(err, html){
if (err) throw err;
console.log(html);
});
```
To dynamically pass the engine, simply use the subscript operator and a variable:
```js
var cons = require('consolidate')
, name = 'swig';
cons[name]('views/page.html', { user: 'tobi' }, function(err, html){
if (err) throw err;
console.log(html);
});
```
## Caching
To enable caching simply pass `{ cache: true }`. Engines _may_ use this option to cache things reading the file contents, compiled `Function`s etc. Engines which do _not_ support this may simply ignore it. All engines that consolidate.js implements I/O for will cache the file contents, ideal for production environments.
```js
var cons = require('consolidate');
cons.swig('views/page.html', { user: 'tobi' }, function(err, html){
if (err) throw err;
console.log(html);
});
```
## Express 3.x example
```js
var express = require('express')
, cons = require('consolidate')
, app = express();
// assign the swig engine to .html files
app.engine('html', cons.swig);
// set .html as the default extension
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
var users = [];
users.push({ name: 'tobi' });
users.push({ name: 'loki' });
users.push({ name: 'jane' });
app.get('/', function(req, res){
res.render('index', {
title: 'Consolidate.js'
});
});
app.get('/users', function(req, res){
res.render('users', {
title: 'Users',
users: users
});
});
app.listen(3000);
console.log('Express server listening on port 3000');
```
## Running tests
Install dev deps:
$ npm install -d
Run the tests:
$ make test
## License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
node_modules/consolidate/index.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./lib/consolidate');

764
node_modules/consolidate/lib/consolidate.js generated vendored Normal file
View File

@ -0,0 +1,764 @@
/*!
* consolidate
* Copyright(c) 2012 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*
* Engines which do not support caching of their file contents
* should use the `read()` function defined in consolidate.js
* On top of this, when an engine compiles to a `Function`,
* these functions should either be cached within consolidate.js
* or the engine itself via `options.cache`. This will allow
* users and frameworks to pass `options.cache = true` for
* `NODE_ENV=production`, however edit the file(s) without
* re-loading the application in development.
*/
/**
* Module dependencies.
*/
var fs = require('fs')
, path = require('path')
, join = path.join
, extname = path.extname
, dirname = path.dirname;
var readCache = {};
/**
* Require cache.
*/
var cacheStore = {};
/**
* Require cache.
*/
var requires = {};
/**
* Clear the cache.
*
* @api public
*/
exports.clearCache = function(){
cacheStore = {};
};
/**
* Conditionally cache `compiled` template based
* on the `options` filename and `.cache` boolean.
*
* @param {Object} options
* @param {Function} compiled
* @return {Function}
* @api private
*/
function cache(options, compiled) {
// cachable
if (compiled && options.filename && options.cache) {
delete readCache[options.filename];
cacheStore[options.filename] = compiled;
return compiled;
}
// check cache
if (options.filename && options.cache) {
return cacheStore[options.filename];
}
return compiled;
}
/**
* Read `path` with `options` with
* callback `(err, str)`. When `options.cache`
* is true the template string will be cached.
*
* @param {String} options
* @param {Function} fn
* @api private
*/
function read(path, options, fn) {
var str = readCache[path];
var cached = options.cache && str && 'string' == typeof str;
// cached (only if cached is a string and not a compiled template function)
if (cached) return fn(null, str);
// read
fs.readFile(path, 'utf8', function(err, str){
if (err) return fn(err);
// remove extraneous utf8 BOM marker
str = str.replace(/^\uFEFF/, '');
if (options.cache) readCache[path] = str;
fn(null, str);
});
}
/**
* Read `path` with `options` with
* callback `(err, str)`. When `options.cache`
* is true the partial string will be cached.
*
* @param {String} options
* @param {Function} fn
* @api private
*/
function readPartials(path, options, fn) {
if (!options.partials) return fn();
var partials = options.partials;
var keys = Object.keys(partials);
function next(index) {
if (index == keys.length) return fn(null);
var key = keys[index];
var file = join(dirname(path), partials[key] + extname(path));
read(file, options, function(err, str){
if (err) return fn(err);
options.partials[key] = str;
next(++index);
});
}
next(0);
}
/**
* fromStringRenderer
*/
function fromStringRenderer(name) {
return function(path, options, fn){
options.filename = path;
readPartials(path, options, function (err) {
if (err) return fn(err);
if (cache(options)) {
exports[name].render('', options, fn);
} else {
read(path, options, function(err, str){
if (err) return fn(err);
exports[name].render(str, options, fn);
});
}
});
};
}
/**
* Jade support.
*/
exports.jade = function(path, options, fn){
var engine = requires.jade;
if (!engine) {
try {
engine = requires.jade = require('jade');
} catch (err) {
engine = requires.jade = require('then-jade');
}
}
engine.renderFile(path, options, fn);
};
/**
* Jade string support.
*/
exports.jade.render = function(str, options, fn){
var engine = requires.jade;
if (!engine) {
try {
engine = requires.jade = require('jade');
} catch (err) {
engine = requires.jade = require('then-jade');
}
}
engine.render(str, options, fn);
};
/**
* Dust support.
*/
exports.dust = fromStringRenderer('dust');
/**
* Dust string support.
*/
exports.dust.render = function(str, options, fn){
var engine = requires.dust;
if (!engine) {
try {
engine = requires.dust = require('dust');
} catch (err) {
try {
engine = requires.dust = require('dustjs-helpers');
} catch (err) {
engine = requires.dust = require('dustjs-linkedin');
}
}
}
var ext = 'dust'
, views = '.';
if (options) {
if (options.ext) ext = options.ext;
if (options.views) views = options.views;
if (options.settings && options.settings.views) views = options.settings.views;
}
if (!options || (options && !options.cache)) engine.cache = {};
engine.onLoad = function(path, callback){
if ('' == extname(path)) path += '.' + ext;
if ('/' !== path[0]) path = views + '/' + path;
read(path, options, callback);
};
try {
var tmpl = cache(options) || cache(options, engine.compileFn(str));
tmpl(options, fn);
} catch (err) {
fn(err);
}
};
/**
* Swig support.
*/
exports.swig = fromStringRenderer('swig');
/**
* Swig string support.
*/
exports.swig.render = function(str, options, fn){
var engine = requires.swig || (requires.swig = require('swig'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Atpl support.
*/
exports.atpl = fromStringRenderer('atpl');
/**
* Atpl string support.
*/
exports.atpl.render = function(str, options, fn){
var engine = requires.atpl || (requires.atpl = require('atpl'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Liquor support,
*/
exports.liquor = fromStringRenderer('liquor');
/**
* Liquor string support.
*/
exports.liquor.render = function(str, options, fn){
var engine = requires.liquor || (requires.liquor = require('liquor'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* EJS support.
*/
exports.ejs = fromStringRenderer('ejs');
/**
* EJS string support.
*/
exports.ejs.render = function(str, options, fn){
var engine = requires.ejs || (requires.ejs = require('ejs'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Eco support.
*/
exports.eco = fromStringRenderer('eco');
/**
* Eco string support.
*/
exports.eco.render = function(str, options, fn){
var engine = requires.eco || (requires.eco = require('eco'));
try {
fn(null, engine.render(str, options));
} catch (err) {
fn(err);
}
};
/**
* Jazz support.
*/
exports.jazz = fromStringRenderer('jazz');
/**
* Jazz string support.
*/
exports.jazz.render = function(str, options, fn){
var engine = requires.jazz || (requires.jazz = require('jazz'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
tmpl.eval(options, function(str){
fn(null, str);
});
} catch (err) {
fn(err);
}
};
/**
* JQTPL support.
*/
exports.jqtpl = fromStringRenderer('jqtpl');
/**
* JQTPL string support.
*/
exports.jqtpl.render = function(str, options, fn){
var engine = requires.jqtpl || (requires.jqtpl = require('jqtpl'));
try {
engine.template(str, str);
fn(null, engine.tmpl(str, options));
} catch (err) {
fn(err);
}
};
/**
* Haml support.
*/
exports.haml = fromStringRenderer('haml');
/**
* Haml string support.
*/
exports.haml.render = function(str, options, fn){
var engine = requires.hamljs || (requires.hamljs = require('hamljs'));
try {
options.locals = options;
fn(null, engine.render(str, options).trimLeft());
} catch (err) {
fn(err);
}
};
/**
* Whiskers support.
*/
exports.whiskers = function(path, options, fn){
var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
engine.__express(path, options, fn);
};
/**
* Whiskers string support.
*/
exports.whiskers.render = function(str, options, fn){
var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
try {
fn(null, engine.render(str, options));
} catch (err) {
fn(err);
}
};
/**
* Coffee-HAML support.
*/
exports['haml-coffee'] = fromStringRenderer('haml-coffee');
/**
* Coffee-HAML string support.
*/
exports['haml-coffee'].render = function(str, options, fn){
var engine = requires.HAMLCoffee || (requires.HAMLCoffee = require('haml-coffee'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Hogan support.
*/
exports.hogan = fromStringRenderer('hogan');
/**
* Hogan string support.
*/
exports.hogan.render = function(str, options, fn){
var engine = requires.hogan || (requires.hogan = require('hogan.js'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl.render(options, options.partials));
} catch (err) {
fn(err);
}
};
/**
* templayed.js support.
*/
exports.templayed = fromStringRenderer('templayed');
/**
* templayed.js string support.
*/
exports.templayed.render = function(str, options, fn){
var engine = requires.templayed || (requires.templayed = require('templayed'));
try {
var tmpl = cache(options) || cache(options, engine(str));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Handlebars support.
*/
exports.handlebars = fromStringRenderer('handlebars');
/**
* Handlebars string support.
*/
exports.handlebars.render = function(str, options, fn) {
var engine = requires.handlebars || (requires.handlebars = require('handlebars'));
try {
for (var partial in options.partials) {
engine.registerPartial(partial, options.partials[partial]);
}
for (var helper in options.helpers) {
engine.registerHelper(helper, options.helpers[helper]);
}
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
}
/**
* Underscore support.
*/
exports.underscore = fromStringRenderer('underscore');
/**
* Underscore string support.
*/
exports.underscore.render = function(str, options, fn) {
var engine = requires.underscore || (requires.underscore = require('underscore'));
try {
var tmpl = cache(options) || cache(options, engine.template(str, null, options));
fn(null, tmpl(options).replace(/\n$/, ''));
} catch (err) {
fn(err);
}
};
/**
* Lodash support.
*/
exports.lodash = fromStringRenderer('lodash');
/**
* Lodash string support.
*/
exports.lodash.render = function(str, options, fn) {
var engine = requires.lodash || (requires.lodash = require('lodash'));
try {
var tmpl = cache(options) || cache(options, engine.template(str, null, options));
fn(null, tmpl(options).replace(/\n$/, ''));
} catch (err) {
fn(err);
}
};
/**
* QEJS support.
*/
exports.qejs = function (path, options, fn) {
try {
var engine = requires.qejs || (requires.qejs = require('qejs'));
engine.renderFile(path, options).nodeify(fn);
} catch (err) {
fn(err);
}
};
/**
* QEJS string support.
*/
exports.qejs.render = function (str, options, fn) {
try {
var engine = requires.qejs || (requires.qejs = require('qejs'));
engine.render(str, options).then(function (result) {
fn(null, result);
}, function (err) {
fn(err);
}).end();
} catch (err) {
fn(err);
}
};
/**
* Walrus support.
*/
exports.walrus = fromStringRenderer('walrus');
/**
* Walrus string support.
*/
exports.walrus.render = function (str, options, fn) {
var engine = requires.walrus || (requires.walrus = require('walrus'));
try {
var tmpl = cache(options) || cache(options, engine.parse(str));
fn(null, tmpl.compile(options));
} catch (err) {
fn(err);
}
};
/**
* Mustache support.
*/
exports.mustache = fromStringRenderer('mustache');
/**
* Mustache string support.
*/
exports.mustache.render = function(str, options, fn) {
var engine = requires.mustache || (requires.mustache = require('mustache'));
try {
fn(null, engine.to_html(str, options, options.partials));
} catch (err) {
fn(err);
}
};
/**
* Just support.
*/
exports.just = function(path, options, fn){
var engine = requires.just;
if (!engine) {
var JUST = require('just');
engine = requires.just = new JUST();
}
engine.configure({ useCache: options.cache });
engine.render(path, options, fn);
};
/**
* Just string support.
*/
exports.just.render = function(str, options, fn){
var JUST = require('just');
var engine = new JUST({ root: { page: str }});
engine.render('page', options, fn);
};
/**
* ECT support.
*/
exports.ect = function(path, options, fn){
var engine = requires.ect;
if (!engine) {
var ECT = require('ect');
engine = requires.ect = new ECT();
}
engine.configure({ cache: options.cache });
engine.render(path, options, fn);
};
/**
* ECT string support.
*/
exports.ect.render = function(str, options, fn){
var ECT = require('ect');
var engine = new ECT({ root: { page: str }});
engine.render('page', options, fn);
};
/**
* mote support.
*/
exports.mote = fromStringRenderer('mote');
/**
* mote string support.
*/
exports.mote.render = function(str, options, fn){
var engine = requires.mote || (requires.mote = require('mote'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Toffee support.
*/
exports.toffee = function(path, options, fn){
var toffee = requires.toffee || (requires.toffee = require('toffee'));
toffee.__consolidate_engine_render(path, options, fn);
};
/**
* Toffee string support.
*/
exports.toffee.render = function(str, options, fn) {
var engine = requires.toffee || (requires.toffee = require('toffee'));
try {
engine.str_render(str, options,fn);
} catch (err) {
fn(err);
}
};
/**
* doT support.
*/
exports.dot = fromStringRenderer('dot');
/**
* doT string support.
*/
exports.dot.render = function (str, options, fn) {
var engine = requires.dot || (requires.dot = require('dot'));
try {
var tmpl = cache(options) || cache(options, engine.compile(str, options && options._def));
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
};
/**
* Ractive support.
*/
exports.ractive = fromStringRenderer('ractive');
/**
* Ractive string support.
*/
exports.ractive.render = function(str, options, fn){
var engine = requires.ractive || (requires.ractive = require('ractive'));
options.template = str;
if (options.data === null || options.data === undefined)
{
options.data = options;
}
try {
fn(null, new engine(options).renderHTML());
} catch (err) {
fn(err);
}
};
/**
* Nunjucks support.
*/
exports.nunjucks = fromStringRenderer('nunjucks');
/**
* Nunjucks string support.
*/
exports.nunjucks.render = function(str, options, fn) {
var engine = requires.nunjucks || (requires.nunjucks = require('nunjucks'));
engine.renderString(str, options, fn);
};

79
node_modules/consolidate/package.json generated vendored Normal file
View File

@ -0,0 +1,79 @@
{
"name": "consolidate",
"version": "0.10.0",
"description": "Template engine consolidation library",
"keywords": [
"template",
"engine",
"view"
],
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca"
},
"devDependencies": {
"mocha": "*",
"should": "*",
"jade": "0.26.0",
"ejs": "0.7.1",
"eco": "1.1.0-rc-3",
"swig": "0.12.0",
"jazz": "0.0.18",
"jqtpl": "1.1.0",
"liquor": "0.0.4",
"lodash": "1.2.0",
"hamljs": "0.6.1",
"whiskers": "0.2.2",
"haml-coffee": "1.4.0",
"hogan.js": "2.0.0",
"dust": "0.3.0",
"dustjs-linkedin": "1.2",
"dustjs-helpers": "1.1.1",
"handlebars": "1.0.7",
"underscore": "1.3.3",
"qejs": "0.0.1",
"walrus": "0.9.0",
"mustache": "0.4.0",
"just": "0.1.8",
"ect": "0.3.5",
"mote": "0.2.0",
"toffee": "0.0.52",
"atpl": ">=0.5.5",
"templayed": ">=0.2.3",
"dot": "1.0.1",
"ractive": "0.3.7",
"nunjucks": "~1.0.0"
},
"main": "index",
"repository": {
"type": "git",
"url": "https://github.com/visionmedia/consolidate.js.git"
},
"scripts": {
"test": "mocha"
},
"bugs": {
"url": "https://github.com/visionmedia/consolidate.js/issues"
},
"homepage": "https://github.com/visionmedia/consolidate.js",
"_id": "consolidate@0.10.0",
"dist": {
"shasum": "81f1a6ceba1247df9cef7a261ce527c2ce538f7a",
"tarball": "http://registry.npmjs.org/consolidate/-/consolidate-0.10.0.tgz"
},
"_from": "consolidate@0.10.0",
"_npmVersion": "1.3.14",
"_npmUser": {
"name": "tjholowaychuk",
"email": "tj@vision-media.ca"
},
"maintainers": [
{
"name": "tjholowaychuk",
"email": "tj@vision-media.ca"
}
],
"directories": {},
"_shasum": "81f1a6ceba1247df9cef7a261ce527c2ce538f7a",
"_resolved": "https://registry.npmjs.org/consolidate/-/consolidate-0.10.0.tgz"
}

1
node_modules/dust/.npmignore generated vendored
View File

@ -1 +0,0 @@
/nbproject

78
node_modules/dust/Makefile generated vendored
View File

@ -1,78 +0,0 @@
#
# Run all tests
#
test:
node test/server.js
#
# Run the benchmarks
#
bench:
node benchmark/server.js
#
# Build the docs
#
docs:
node docs/build.js
#
# Build the parser
#
parser:
node src/build.js
#
# Build dust.js
#
SRC = lib
VERSION = ${shell cat package.json | grep version | grep -o '[0-9]\.[0-9]\.[0-9]\+'}
CORE = dist/dust-core-${VERSION}.js
CORE_MIN = dist/dust-core-${VERSION}.min.js
FULL = dist/dust-full-${VERSION}.js
FULL_MIN = dist/dust-full-${VERSION}.min.js
define HEADER
//
// Dust - Asynchronous Templating v${VERSION}
// http://akdubya.github.com/dustjs
//
// Copyright (c) 2010, Aleksander Williams
// Released under the MIT License.
//
endef
export HEADER
dust:
@@mkdir -p dist
@@touch ${CORE}
@@echo "$$HEADER" > ${CORE}
@@cat ${SRC}/dust.js >> ${CORE}
@@echo ${CORE} built
@@touch ${FULL}
@@echo "$$HEADER" > ${FULL}
@@cat ${SRC}/dust.js\
${SRC}/compiler.js\
${SRC}/parser.js >> ${FULL}
@@echo ${FULL} built
min: dust
@@echo minifying...
@@echo "$$HEADER" > ${CORE_MIN}
@@echo "$$HEADER" > ${FULL_MIN}
@@minmin ${CORE} >> ${CORE_MIN}
@@minmin ${FULL} >> ${FULL_MIN}
clean:
git rm dist/*
release: clean docs min
git add dist/*
git commit -a -m "release v${VERSION}"
git tag -a -m "version v${VERSION}" v${VERSION}
npm publish
.PHONY: test docs bench parser

51
node_modules/dust/README.md generated vendored
View File

@ -1,51 +0,0 @@
Dust
====
> Asynchronous templates for the browser and node.js
#### <http://akdubya.github.com/dustjs> #
Why?
----
I like [Mustache](http://mustache.github.com) and variants but none of them offers quite what I need.
Use Dust if you want these things:
* async/streaming operation
* browser/node compatibility
* extended Mustache/ctemplate syntax
* clean, low-level API
* [high performance](http://akdubya.github.com/dustjs/benchmark/index.html)
* composable templates
Composable templates?
---------------------
{^xhr}
{>base_template/}
{:else}
{+main/}
{/xhr}
{<title}
Child Title
{/title}
{<main}
Child Content
{/main}
Installation
------------
In Node:
$ npm install dust
To render compiled templates in the browser:
<script src="dust-core-0.3.0.min.js"></script>
Demo & Guide
------------
Extensive docs and a full demo are available at <http://akdubya.github.com/dustjs>

3
node_modules/dust/TODO generated vendored
View File

@ -1,3 +0,0 @@
- Optimize static strings
- Improve interface to compile options (formatting, etc.)
- Refactor compiler

View File

@ -1,161 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>shootout</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
background-color: #eee;
font-family: Helvetica, Arial, sans-serif;
margin: 0 10%;
text-shadow: white 1px 1px 0px;
}
p {
color: #777;
}
#header p {
color: #555;
font-size: 1.1em;
font-weight: bold;
}
h1 {
font-size: 7em;
font-weight: bold;
color: #333;
margin-top: 0.10em;
margin-bottom: -0.25em;
}
.chart {
border: 4px solid #ccc;
float: left;
margin-right: 1em;
margin-bottom: 1em;
}
#control {
margin-bottom: 1em;
}
#progress {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border: 1px solid #aaa;
padding: 2px;
}
#progress div {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
height: 25px;
width: 0%;
background-color: #888;
}
</style>
</head>
<body>
<div id="header">
<h1>shootout</h1>
<p>Template benchmarks (ops per millisecond)</p>
</div>
<div id="control">
<div id="progress"><div></div></div>
<button id="run" style="display:none;">Run</button>
</div>
<div id="content">
<div id="charts"></div>
<p style="clear: both">Targets: <a href="http://akdubya.github.com/dustjs">Dust</a>, <a href="http://github.com/wycats/handlebars.js">Handlebars</a>, <a href="http://mustache.github.com/">Mustache</a>, <a href="http://api.jquery.com/tmpl/">jquery-tmpl</a>. Each benchmark runs once using an adaptive test cycles algorithm similar to the one found in <a href="http://github.com/broofa/jslitmus">jslitmus</a>.</p>
</div>
<script src="../vendor/jquery.min.js"></script>
<script src="uubench.js"></script>
<script src="../dist/dust-full-0.2.5.min.js"></script>
<script src="suites/dust_suite.js"></script>
<script src="suites/mustache_suite.js"></script>
<script src="suites/handlebars_suite.js"></script>
<script src="suites/jquery_suite.js"></script>
<script src="http://github.com/wycats/handlebars.js/raw/766497bb553a926c046c5e5b50ee35529d168ba5/lib/handlebars.js"></script>
<script src="http://github.com/janl/mustache.js/raw/master/mustache.js"></script>
<script src="http://github.com/jquery/jquery-tmpl/raw/master/jquery.tmpl.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {packages: ['imagechart']});
</script>
<script>
$(document).ready(function(){
var testQueue = [];
var $bar = $('#progress > div');
var tick;
function runAll() {
$bar.css('width', "0%");
$('#progress').show();
for (var key in dustBench.benches) { testQueue.push(key) }
tick = 100 / testQueue.length;
$('#charts').empty();
next();
}
function next() {
var test = testQueue.shift();
if (test) {
runSuite(test);
} else {
$('#progress').fadeOut(1000, function() {
$('#run').fadeIn();
});
}
}
function runSuite(type) {
var rows = [];
var suite = new uubench.Suite({
iterations: 1000,
result: function(name, stats) {
var opms = stats.iterations/stats.elapsed;
rows.push([name, opms]);
},
start: function() {
$('#charts').append("<div id=\"" + type + "\" class=\"chart\"></div>");
},
done: function() {
var pct = parseFloat($bar.css('width')) + tick;
drawBarChart(type, rows);
$('#progress > div').css('width', pct + "%");
next();
}
});
dustBench(suite, type, "dust");
handlebarsBench(suite, type, "handlebars");
mustacheBench(suite, type, "mustache");
jqueryBench(suite, type, "jquery");
suite.run();
}
function drawBarChart(type, rows) {
var dataTable = new google.visualization.DataTable();
dataTable.addColumn("string", "engine");
dataTable.addColumn("number", "ops");
dataTable.addRows(rows);
var chart = new google.visualization.ImageChart(document.getElementById(type));
chart.draw(dataTable, {title: type, cht: 'bhs', chs: '420x175'});
}
$('#run').click(function() {
$('#run').hide();
runAll();
return false;
});
runAll();
});
</script>
</body>
</html>

View File

@ -1,33 +0,0 @@
var uubench = require('./uubench'),
dust = require('../lib/dust'),
dustBench = require('./suites/dust_suite').dustBench;
uubench.nextTick = process.nextTick;
var suite = new uubench.Suite({
iterations: 10000,
result: function(name, stats) {
var opms = stats.iterations/stats.elapsed;
console.log(pad(12, name + ": "), pad(5, Math.round(opms), true));
}
});
function pad(amt, val, pre) {
val = String(val);
var len = amt - val.length, out = '';
for (var i=0; i<len; i++) {
out += ' ';
}
return pre ? out + val : val + out;
}
console.log("ops/ms");
console.log("------");
global.dust = dust;
for (var key in dustBench.benches) {
dustBench(suite, key);
}
suite.run();

View File

@ -1,111 +0,0 @@
(function(exports){
var benches = {
string: {
source: "Hello World!",
context: {}
},
replace: {
source: "Hello {name}! You have {count} new messages.",
context: { name: "Mick", count: 30 }
},
array: {
source: "{#names}{name}{/names}",
context: { names: [
{ name: "Moe" },
{ name: "Larry" },
{ name: "Curly" },
{ name: "Shemp" }
]
}
},
object: {
source: "{#person}{name}{age}{/person}",
context: { person: { name: "Larry", age: 45 } }
},
partial: {
source: "{#peeps}{>replace/}{/peeps}",
context: { peeps: [
{ name: "Moe", count: 15 },
{ name: "Larry", count: 5 },
{ name: "Curly", count: 0 }
]
}
},
recursion: {
source: "{name}{#kids}{>recursion:./}{/kids}",
context: {
name: '1',
kids: [
{
name: '1.1',
kids: [
{name: '1.1.1'}
]
}
]
}
},
filter: {
source: "{#filter}foo {bar}{/filter}",
context: {
filter: function(chunk, context, bodies) {
return chunk.tap(function(data) {
return data.toUpperCase();
}).render(bodies.block, context).untap();
},
bar: "bar"
}
},
complex: {
source: "<h1>{header}</h1>\n" +
"{?items}\n" +
" <ul>\n" +
" {#items}\n" +
" {#current}\n" +
" <li><strong>{name}</strong></li>\n" +
" {:else}\n" +
" <li><a href=\"{url}\">{name}</a></li>\n" +
" {/current}\n" +
" {/items}\n" +
" </ul>\n" +
"{:else}\n" +
" <p>The list is empty.</p>\n" +
"{/items}",
context: {
header: function() {
return "Colors";
},
items: [
{name: "red", current: true, url: "#Red"},
{name: "green", current: false, url: "#Green"},
{name: "blue", current: false, url: "#Blue"}
]
}
}
}
exports.dustBench = function(suite, name, id) {
var bench = benches[name],
ctx = bench.context;
dust.loadSource(dust.compile(bench.source, name));
suite.bench(id || name, function(next) {
dust.render(name, ctx, function() {
next();
});
});
};
exports.dustBench.benches = benches;
})(typeof exports !== "undefined" ? exports : window);

View File

@ -1,101 +0,0 @@
(function(exports){
var benches = {
string: {
source: "Hello World!",
context: {}
},
replace: {
source: "Hello {{name}}! You have {{count}} new messages.",
context: { name: "Mick", count: 30 }
},
array: {
source: "{{#names}}{{name}}{{/names}}",
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] }
},
object: {
source: "{{#person}}{{name}}{{age}}{{/person}}",
context: { person: { name: "Larry", age: 45 } }
},
partial: {
source: "{{#peeps}}{{>replace}}{{/peeps}}",
context: { peeps: [{name: "Moe", count: 15}, {name: "Larry", count: 5}, {name: "Curly", count: 1}] },
partials: { replace: "Hello {{name}}! You have {{count}} new messages." }
},
recursion: {
source: "{{name}}{{#kids}}{{>recursion}}{{/kids}}",
context: {
name: '1',
kids: [
{
name: '1.1',
kids: [
{name: '1.1.1'}
]
}
]
},
partials: { recursion: "{{name}}{{#kids}}{{>recursion}}{{/kids}}" }
},
filter: {
source: "{{#filter}}foo {{bar}}{{/filter}}",
context: {
filter: function(ctx, fn) {
return fn(ctx).toUpperCase();
},
bar: "bar"
}
},
complex: {
source: "<h1>{{header}}</h1>{{#hasItems}}<ul>{{#items}}{{#current}}" +
"<li><strong>{{name}}</strong></li>{{/current}}{{^current}}" +
"<li><a href=\"{{url}}\">{{name}}</a></li>{{/current}}" +
"{{/items}}</ul>{{^}}<p>The list is empty.</p>{{/hasItems}}",
context: {
header: function() {
return "Colors";
},
items: [
{name: "red", current: true, url: "#Red"},
{name: "green", current: false, url: "#Green"},
{name: "blue", current: false, url: "#Blue"}
],
hasItems: function(ctx, fn) {
if (ctx.items.length) {
return fn(ctx);
}
}
}
}
}
exports.handlebarsBench = function(suite, name, id) {
var bench = benches[name],
fn = Handlebars.compile(bench.source),
ctx = bench.context,
partials = {};
if (bench.partials) {
for (var key in bench.partials) {
partials[key] = Handlebars.compile(bench.partials[key]);
}
}
suite.bench(id || name, function(next) {
fn(ctx, {partials: partials});
next();
});
}
exports.handlebarsBench.benches = benches;
})(typeof exports !== "undefined" ? exports : window);

View File

@ -1,84 +0,0 @@
(function(exports){
var benches = {
string: {
source: "Hello World!",
context: {}
},
replace: {
source: "Hello ${name}! You have ${count} new messages.",
context: { name: "Mick", count: 30 }
},
array: {
source: "{{each names}}${name}{{/each}}",
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] }
},
object: {
source: "${person.name}${person.age}",
context: { person: { name: "Larry", age: 45 } }
},
partial: {
source: "{{tmpl(peeps) \"replace\"}}",
context: { peeps: [{name: "Moe", count: 15}, {name: "Larry", count: 5}, {name: "Curly", count: 1}] }
},
recursion: {
source: "${name}{{tmpl(kids) \"recursion\"}}",
context: {
name: '1',
kids: [
{
name: '1.1',
kids: [
{name: '1.1.1', kids: []}
]
}
]
}
},
filter: {
source: "FOO ${bar.toUpperCase()}",
context: {
bar: "bar"
}
},
complex: {
source: "<h1>${header}</h1>{{if items.length}}<ul>{{each items}}{{if current}}" +
"<li><strong>${name}</strong></li>{{else}}" +
"<li><a href=\"${url}\">${name}</a></li>{{/if}}" +
"{{/each}}</ul>{{else}}<p>The list is empty.</p>{{/if}}",
context: {
header: function() {
return "Colors";
},
items: [
{name: "red", current: true, url: "#Red"},
{name: "green", current: false, url: "#Green"},
{name: "blue", current: false, url: "#Blue"}
]
}
}
}
exports.jqueryBench = function(suite, name, id) {
var bench = benches[name],
fn = $.template(name, bench.source),
ctx = bench.context;
suite.bench(id || name, function(next) {
$.tmpl(fn, ctx);
next();
});
}
exports.jqueryBench.benches = benches;
})(typeof exports !== "undefined" ? exports : window);

View File

@ -1,97 +0,0 @@
(function(exports){
var benches = {
string: {
source: "Hello World!",
context: {}
},
replace: {
source: "Hello {{name}}! You have {{count}} new messages.",
context: { name: "Mick", count: 30 }
},
array: {
source: "{{#names}}{{name}}{{/names}}",
context: { names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] }
},
object: {
source: "{{#person}}{{name}}{{age}}{{/person}}",
context: { person: { name: "Larry", age: 45 } }
},
partial: {
source: "{{#peeps}}{{>replace}}{{/peeps}}",
context: { peeps: [{name: "Moe", count: 15}, {name: "Larry", count: 5}, {name: "Curly", count: 1}] },
partials: { replace: "Hello {{name}}! You have {{count}} new messages." }
},
recursion: {
source: "{{name}}{{#kids}}{{>recursion}}{{/kids}}",
context: {
name: '1',
kids: [
{
name: '1.1',
kids: [
{name: '1.1.1', kids: []}
]
}
]
},
partials: { recursion: "{{name}}{{#kids}}{{>recursion}}{{/kids}}" }
},
filter: {
source: "{{#filter}}foo {{bar}}{{/filter}}",
context: {
filter: function() {
return function(text, render) {
return render(text).toUpperCase();
}
},
bar: "bar"
}
},
complex: {
source: "<h1>{{header}}</h1>{{#hasItems}}<ul>{{#items}}{{#current}}" +
"<li><strong>{{name}}</strong></li>{{/current}}{{^current}}" +
"<li><a href=\"{{url}}\">{{name}}</a></li>{{/current}}" +
"{{/items}}</ul>{{/hasItems}}{{^hasItems}}<p>The list is empty.</p>{{/hasItems}}",
context: {
header: function() {
return "Colors";
},
items: [
{name: "red", current: true, url: "#Red"},
{name: "green", current: false, url: "#Green"},
{name: "blue", current: false, url: "#Blue"}
],
hasItems: function() {
return this.items.length !== 0;
},
empty: function() {
return this.items.length === 0;
}
}
}
}
exports.mustacheBench = function(suite, name, id) {
var bench = benches[name],
src = bench.source,
ctx = bench.context,
partials = bench.partials;
suite.bench(id || name, function(next) {
Mustache.to_html(src, ctx, partials);
next();
});
}
exports.mustacheBench.benches = benches;
})(typeof exports !== "undefined" ? exports : window);

View File

@ -1,107 +0,0 @@
(function(uubench){
function Bench(id, test, options, callback) {
this.id = id;
this.options = options;
this.test = test;
this.loop = test.length > 1;
this.callback = callback;
}
Bench.prototype.run = function(iter) {
var self = this, fn = self.test,
checkfn = self.options.type === "adaptive" ? adaptive : fixed,
i = iter, pend = i,
min = self.options.min, start;
if (self.loop) {
pend = 1;
start = new Date();
fn(checkfn, i);
} else {
start = new Date();
while (i--) {
fn(checkfn);
}
}
function fixed() {
if (--pend === 0) {
var elapsed = new Date() - start;
self.callback({iterations: iter, elapsed: elapsed});
}
}
function adaptive() {
if (--pend === 0) {
var elapsed = new Date() - start;
if (elapsed < min) {
self.run(iter*2);
} else {
self.callback({iterations: iter, elapsed: elapsed});
}
}
}
}
uubench.Bench = Bench;
uubench.defaults = {
type: "adaptive", // adaptive or fixed
iterations: 10, // starting iterations
min: 100, // minimum run time (ms) - adaptive only
delay: 100 // delay between tests (ms)
}
function Suite(opts) {
for (var key in uubench.defaults) {
if (opts[key] === undefined) {
opts[key] = uubench.defaults[key];
}
}
this.options = opts;
this.tests = [];
}
Suite.prototype.bench = function(name, fn) {
var self = this;
self.tests.push(new Bench(name, fn, this.options, function(stats) {
self.emit("result", name, stats);
self.pending--;
self.check();
}));
}
Suite.prototype.run = function() {
if (this.pending) return;
var self = this, len = self.tests.length;
self.emit("start", self.tests);
self.start = new Date().getTime();
self.pending = len;
for (var i=0; i<len; i++) {
self.runOne(i);
}
}
Suite.prototype.runOne = function(idx) {
var self = this;
setTimeout(function() {
self.tests[idx].run(self.options.iterations);
}, self.options.delay);
}
Suite.prototype.check = function() {
if (this.pending) return;
this.emit("done", new Date().getTime() - this.start);
}
Suite.prototype.emit = function(type) {
var event = this.options[type];
if (event) {
event.apply(this, Array.prototype.slice.call(arguments, 1));
}
}
uubench.Suite = Suite;
})(typeof exports !== 'undefined' ? exports : window.uubench = {});

View File

@ -1,522 +0,0 @@
//
// Dust - Asynchronous Templating v0.3.0
// http://akdubya.github.com/dustjs
//
// Copyright (c) 2010, Aleksander Williams
// Released under the MIT License.
//
var dust = {};
(function(dust) {
dust.cache = {};
dust.register = function(name, tmpl) {
if (!name) return;
dust.cache[name] = tmpl;
};
dust.render = function(name, context, callback) {
var chunk = new Stub(callback).head;
dust.load(name, chunk, Context.wrap(context)).end();
};
dust.stream = function(name, context) {
var stream = new Stream();
dust.nextTick(function() {
dust.load(name, stream.head, Context.wrap(context)).end();
});
return stream;
};
dust.renderSource = function(source, context, callback) {
return dust.compileFn(source)(context, callback);
};
dust.compileFn = function(source, name) {
var tmpl = dust.loadSource(dust.compile(source, name));
return function(context, callback) {
var master = callback ? new Stub(callback) : new Stream();
dust.nextTick(function() {
tmpl(master.head, Context.wrap(context)).end();
});
return master;
}
};
dust.load = function(name, chunk, context) {
var tmpl = dust.cache[name];
if (tmpl) {
return tmpl(chunk, context);
} else {
if (dust.onLoad) {
return chunk.map(function(chunk) {
dust.onLoad(name, function(err, src) {
if (err) return chunk.setError(err);
if (!dust.cache[name]) dust.loadSource(dust.compile(src, name));
dust.cache[name](chunk, context).end();
});
});
}
return chunk.setError(new Error("Template Not Found: " + name));
}
};
dust.loadSource = function(source, path) {
return eval(source);
};
if (Array.isArray) {
dust.isArray = Array.isArray;
} else {
dust.isArray = function(arr) {
return Object.prototype.toString.call(arr) == "[object Array]";
};
}
dust.nextTick = function(callback) {
setTimeout(callback, 0);
}
dust.isEmpty = function(value) {
if (dust.isArray(value) && !value.length) return true;
if (value === 0) return false;
return (!value);
};
dust.filter = function(string, auto, filters) {
if (filters) {
for (var i=0, len=filters.length; i<len; i++) {
var name = filters[i];
if (name === "s") {
auto = null;
} else {
string = dust.filters[name](string);
}
}
}
if (auto) {
string = dust.filters[auto](string);
}
return string;
};
dust.filters = {
h: function(value) { return dust.escapeHtml(value); },
j: function(value) { return dust.escapeJs(value); },
u: encodeURI,
uc: encodeURIComponent
}
function Context(stack, global, blocks) {
this.stack = stack;
this.global = global;
this.blocks = blocks;
}
dust.makeBase = function(global) {
return new Context(new Stack(), global);
}
Context.wrap = function(context) {
if (context instanceof Context) {
return context;
}
return new Context(new Stack(context));
}
Context.prototype.get = function(key) {
var ctx = this.stack, value;
while(ctx) {
if (ctx.isObject) {
value = ctx.head[key];
if (!(value === undefined)) {
return value;
}
}
ctx = ctx.tail;
}
return this.global ? this.global[key] : undefined;
};
Context.prototype.getPath = function(cur, down) {
var ctx = this.stack,
len = down.length;
if (cur && len === 0) return ctx.head;
if (!ctx.isObject) return undefined;
ctx = ctx.head;
var i = 0;
while(ctx && i < len) {
ctx = ctx[down[i]];
i++;
}
return ctx;
};
Context.prototype.push = function(head, idx, len) {
return new Context(new Stack(head, this.stack, idx, len), this.global, this.blocks);
};
Context.prototype.rebase = function(head) {
return new Context(new Stack(head), this.global, this.blocks);
};
Context.prototype.current = function() {
return this.stack.head;
};
Context.prototype.getBlock = function(key) {
var blocks = this.blocks;
if (!blocks) return;
var len = blocks.length, fn;
while (len--) {
fn = blocks[len][key];
if (fn) return fn;
}
}
Context.prototype.shiftBlocks = function(locals) {
var blocks = this.blocks;
if (locals) {
if (!blocks) {
newBlocks = [locals];
} else {
newBlocks = blocks.concat([locals]);
}
return new Context(this.stack, this.global, newBlocks);
}
return this;
}
function Stack(head, tail, idx, len) {
this.tail = tail;
this.isObject = !dust.isArray(head) && head && typeof head === "object";
this.head = head;
this.index = idx;
this.of = len;
}
function Stub(callback) {
this.head = new Chunk(this);
this.callback = callback;
this.out = '';
}
Stub.prototype.flush = function() {
var chunk = this.head;
while (chunk) {
if (chunk.flushable) {
this.out += chunk.data;
} else if (chunk.error) {
this.callback(chunk.error);
this.flush = function() {};
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.callback(null, this.out);
}
function Stream() {
this.head = new Chunk(this);
}
Stream.prototype.flush = function() {
var chunk = this.head;
while(chunk) {
if (chunk.flushable) {
this.emit('data', chunk.data);
} else if (chunk.error) {
this.emit('error', chunk.error);
this.flush = function() {};
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.emit('end');
}
Stream.prototype.emit = function(type, data) {
var events = this.events;
if (events && events[type]) {
events[type](data);
}
}
Stream.prototype.on = function(type, callback) {
if (!this.events) {
this.events = {};
}
this.events[type] = callback;
return this;
}
function Chunk(root, next, taps) {
this.root = root;
this.next = next;
this.data = '';
this.flushable = false;
this.taps = taps;
}
Chunk.prototype.write = function(data) {
var taps = this.taps;
if (taps) {
data = taps.go(data);
}
this.data += data;
return this;
}
Chunk.prototype.end = function(data) {
if (data) {
this.write(data);
}
this.flushable = true;
this.root.flush();
return this;
}
Chunk.prototype.map = function(callback) {
var cursor = new Chunk(this.root, this.next, this.taps),
branch = new Chunk(this.root, cursor, this.taps);
this.next = branch;
this.flushable = true;
callback(branch);
return cursor;
}
Chunk.prototype.tap = function(tap) {
var taps = this.taps;
if (taps) {
this.taps = taps.push(tap);
} else {
this.taps = new Tap(tap);
}
return this;
}
Chunk.prototype.untap = function() {
this.taps = this.taps.tail;
return this;
}
Chunk.prototype.render = function(body, context) {
return body(this, context);
}
Chunk.prototype.reference = function(elem, context, auto, filters) {
if (typeof elem === "function") {
elem = elem(this, context, null, {auto: auto, filters: filters});
if (elem instanceof Chunk) {
return elem;
}
}
if (!dust.isEmpty(elem)) {
return this.write(dust.filter(elem, auto, filters));
} else {
return this;
}
};
Chunk.prototype.section = function(elem, context, bodies, params) {
if (typeof elem === "function") {
elem = elem(this, context, bodies, params);
if (elem instanceof Chunk) {
return elem;
}
}
var body = bodies.block,
skip = bodies['else'];
if (params) {
context = context.push(params);
}
if (dust.isArray(elem)) {
if (body) {
var len = elem.length, chunk = this;
for (var i=0; i<len; i++) {
chunk = body(chunk, context.push(elem[i], i, len));
}
return chunk;
}
} else if (elem === true) {
if (body) return body(this, context);
} else if (elem || elem === 0) {
if (body) return body(this, context.push(elem));
} else if (skip) {
return skip(this, context);
}
return this;
};
Chunk.prototype.exists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (!dust.isEmpty(elem)) {
if (body) return body(this, context);
} else if (skip) {
return skip(this, context);
}
return this;
}
Chunk.prototype.notexists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (dust.isEmpty(elem)) {
if (body) return body(this, context);
} else if (skip) {
return skip(this, context);
}
return this;
}
Chunk.prototype.block = function(elem, context, bodies) {
var body = bodies.block;
if (elem) {
body = elem;
}
if (body) {
return body(this, context);
}
return this;
};
Chunk.prototype.partial = function(elem, context) {
if (typeof elem === "function") {
return this.capture(elem, context, function(name, chunk) {
dust.load(name, chunk, context).end();
});
}
return dust.load(elem, this, context);
};
Chunk.prototype.helper = function(name, context, bodies, params) {
return dust.helpers[name](this, context, bodies, params);
};
Chunk.prototype.capture = function(body, context, callback) {
return this.map(function(chunk) {
var stub = new Stub(function(err, out) {
if (err) {
chunk.setError(err);
} else {
callback(out, chunk);
}
});
body(stub.head, context).end();
});
};
Chunk.prototype.setError = function(err) {
this.error = err;
this.root.flush();
return this;
};
dust.helpers = {
sep: function(chunk, context, bodies) {
if (context.stack.index === context.stack.of - 1) {
return chunk;
}
return bodies.block(chunk, context);
},
idx: function(chunk, context, bodies) {
return bodies.block(chunk, context.push(context.stack.index));
}
}
function Tap(head, tail) {
this.head = head;
this.tail = tail;
}
Tap.prototype.push = function(tap) {
return new Tap(tap, this);
};
Tap.prototype.go = function(value) {
var tap = this;
while(tap) {
value = tap.head(value);
tap = tap.tail;
}
return value;
};
var HCHARS = new RegExp(/[&<>\"]/),
AMP = /&/g,
LT = /</g,
GT = />/g,
QUOT = /\"/g;
dust.escapeHtml = function(s) {
if (typeof s === "string") {
if (!HCHARS.test(s)) {
return s;
}
return s.replace(AMP,'&amp;').replace(LT,'&lt;').replace(GT,'&gt;').replace(QUOT,'&quot;');
}
return s;
};
var BS = /\\/g,
CR = /\r/g,
LS = /\u2028/g,
PS = /\u2029/g,
NL = /\n/g,
LF = /\f/g,
SQ = /'/g,
DQ = /"/g,
TB = /\t/g;
dust.escapeJs = function(s) {
if (typeof s === "string") {
return s
.replace(BS, '\\\\')
.replace(DQ, '\\"')
.replace(SQ, "\\'")
.replace(CR, '\\r')
.replace(LS, '\\u2028')
.replace(PS, '\\u2029')
.replace(NL, '\\n')
.replace(LF, '\\f')
.replace(TB, "\\t");
}
return s;
};
})(dust);
if (typeof exports !== "undefined") {
if (typeof process !== "undefined") {
require('./server')(dust);
}
module.exports = dust;
}

View File

@ -1,21 +0,0 @@
//
// Dust - Asynchronous Templating v0.3.0
// http://akdubya.github.com/dustjs
//
// Copyright (c) 2010, Aleksander Williams
// Released under the MIT License.
//
var dust={};
(function(d){function h(a,b,c){this.stack=a;this.global=b;this.blocks=c}function k(a,b,c,e){this.tail=b;this.isObject=!d.isArray(a)&&a&&typeof a==="object";this.head=a;this.index=c;this.of=e}function l(a){this.head=new f(this);this.callback=a;this.out=""}function j(){this.head=new f(this)}function f(a,b,c){this.root=a;this.next=b;this.data="";this.flushable=false;this.taps=c}function m(a,b){this.head=a;this.tail=b}d.cache={};d.register=function(a,b){if(a)d.cache[a]=b};d.render=function(a,b,c){c=(new l(c)).head;
d.load(a,c,h.wrap(b)).end()};d.stream=function(a,b){var c=new j;d.nextTick(function(){d.load(a,c.head,h.wrap(b)).end()});return c};d.renderSource=function(a,b,c){return d.compileFn(a)(b,c)};d.compileFn=function(a,b){var c=d.loadSource(d.compile(a,b));return function(e,g){var i=g?new l(g):new j;d.nextTick(function(){c(i.head,h.wrap(e)).end()});return i}};d.load=function(a,b,c){var e=d.cache[a];if(e)return e(b,c);else{if(d.onLoad)return b.map(function(g){d.onLoad(a,function(i,n){if(i)return g.setError(i);
d.cache[a]||d.loadSource(d.compile(n,a));d.cache[a](g,c).end()})});return b.setError(Error("Template Not Found: "+a))}};d.loadSource=function(a){return eval(a)};d.isArray=Array.isArray?Array.isArray:function(a){return Object.prototype.toString.call(a)=="[object Array]"};d.nextTick=function(a){setTimeout(a,0)};d.isEmpty=function(a){if(d.isArray(a)&&!a.length)return true;if(a===0)return false;return!a};d.filter=function(a,b,c){if(c)for(var e=0,g=c.length;e<g;e++){var i=c[e];if(i==="s")b=null;else a=
d.filters[i](a)}if(b)a=d.filters[b](a);return a};d.filters={h:function(a){return d.escapeHtml(a)},j:function(a){return d.escapeJs(a)},u:encodeURI,uc:encodeURIComponent};d.makeBase=function(a){return new h(new k,a)};h.wrap=function(a){if(a instanceof h)return a;return new h(new k(a))};h.prototype.get=function(a){for(var b=this.stack,c;b;){if(b.isObject){c=b.head[a];if(c!==undefined)return c}b=b.tail}return this.global?this.global[a]:undefined};h.prototype.getPath=function(a,b){var c=this.stack,e=b.length;
if(a&&e===0)return c.head;if(c.isObject){c=c.head;for(var g=0;c&&g<e;){c=c[b[g]];g++}return c}};h.prototype.push=function(a,b,c){return new h(new k(a,this.stack,b,c),this.global,this.blocks)};h.prototype.rebase=function(a){return new h(new k(a),this.global,this.blocks)};h.prototype.current=function(){return this.stack.head};h.prototype.getBlock=function(a){var b=this.blocks;if(b)for(var c=b.length,e;c--;)if(e=b[c][a])return e};h.prototype.shiftBlocks=function(a){var b=this.blocks;if(a){newBlocks=
b?b.concat([a]):[a];return new h(this.stack,this.global,newBlocks)}return this};l.prototype.flush=function(){for(var a=this.head;a;){if(a.flushable)this.out+=a.data;else{if(a.error){this.callback(a.error);this.flush=function(){}}return}this.head=a=a.next}this.callback(null,this.out)};j.prototype.flush=function(){for(var a=this.head;a;){if(a.flushable)this.emit("data",a.data);else{if(a.error){this.emit("error",a.error);this.flush=function(){}}return}this.head=a=a.next}this.emit("end")};j.prototype.emit=
function(a,b){var c=this.events;c&&c[a]&&c[a](b)};j.prototype.on=function(a,b){if(!this.events)this.events={};this.events[a]=b;return this};f.prototype.write=function(a){var b=this.taps;if(b)a=b.go(a);this.data+=a;return this};f.prototype.end=function(a){a&&this.write(a);this.flushable=true;this.root.flush();return this};f.prototype.map=function(a){var b=new f(this.root,this.next,this.taps),c=new f(this.root,b,this.taps);this.next=c;this.flushable=true;a(c);return b};f.prototype.tap=function(a){var b=
this.taps;this.taps=b?b.push(a):new m(a);return this};f.prototype.untap=function(){this.taps=this.taps.tail;return this};f.prototype.render=function(a,b){return a(this,b)};f.prototype.reference=function(a,b,c,e){if(typeof a==="function"){a=a(this,b,null,{auto:c,filters:e});if(a instanceof f)return a}return d.isEmpty(a)?this:this.write(d.filter(a,c,e))};f.prototype.section=function(a,b,c,e){if(typeof a==="function"){a=a(this,b,c,e);if(a instanceof f)return a}var g=c.block;c=c["else"];if(e)b=b.push(e);
if(d.isArray(a)){if(g){e=a.length;c=this;for(var i=0;i<e;i++)c=g(c,b.push(a[i],i,e));return c}}else if(a===true){if(g)return g(this,b)}else if(a||a===0){if(g)return g(this,b.push(a))}else if(c)return c(this,b);return this};f.prototype.exists=function(a,b,c){var e=c.block;c=c["else"];if(d.isEmpty(a)){if(c)return c(this,b)}else if(e)return e(this,b);return this};f.prototype.notexists=function(a,b,c){var e=c.block;c=c["else"];if(d.isEmpty(a)){if(e)return e(this,b)}else if(c)return c(this,b);return this};
f.prototype.block=function(a,b,c){c=c.block;if(a)c=a;if(c)return c(this,b);return this};f.prototype.partial=function(a,b){if(typeof a==="function")return this.capture(a,b,function(c,e){d.load(c,e,b).end()});return d.load(a,this,b)};f.prototype.helper=function(a,b,c,e){return d.helpers[a](this,b,c,e)};f.prototype.capture=function(a,b,c){return this.map(function(e){var g=new l(function(i,n){i?e.setError(i):c(n,e)});a(g.head,b).end()})};f.prototype.setError=function(a){this.error=a;this.root.flush();
return this};d.helpers={sep:function(a,b,c){if(b.stack.index===b.stack.of-1)return a;return c.block(a,b)},idx:function(a,b,c){return c.block(a,b.push(b.stack.index))}};m.prototype.push=function(a){return new m(a,this)};m.prototype.go=function(a){for(var b=this;b;){a=b.head(a);b=b.tail}return a};var o=RegExp(/[&<>\"]/),p=/&/g,q=/</g,r=/>/g,s=/\"/g;d.escapeHtml=function(a){if(typeof a==="string"){if(!o.test(a))return a;return a.replace(p,"&amp;").replace(q,"&lt;").replace(r,"&gt;").replace(s,"&quot;")}return a};
var t=/\\/g,u=/\r/g,v=/\u2028/g,w=/\u2029/g,x=/\n/g,y=/\f/g,z=/'/g,A=/"/g,B=/\t/g;d.escapeJs=function(a){if(typeof a==="string")return a.replace(t,"\\\\").replace(A,'\\"').replace(z,"\\'").replace(u,"\\r").replace(v,"\\u2028").replace(w,"\\u2029").replace(x,"\\n").replace(y,"\\f").replace(B,"\\t");return a}})(dust);if(typeof exports!=="undefined"){typeof process!=="undefined"&&require("./server")(dust);module.exports=dust};

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +0,0 @@
//
// Dust - Asynchronous Templating v0.3.0
// http://akdubya.github.com/dustjs
//
// Copyright (c) 2010, Aleksander Williams
// Released under the MIT License.
//
var dust={};
(function(o){function z(e,k,l){this.stack=e;this.global=k;this.blocks=l}function H(e,k,l,x){this.tail=k;this.isObject=!o.isArray(e)&&e&&typeof e==="object";this.head=e;this.index=l;this.of=x}function p(e){this.head=new B(this);this.callback=e;this.out=""}function J(){this.head=new B(this)}function B(e,k,l){this.root=e;this.next=k;this.data="";this.flushable=false;this.taps=l}function r(e,k){this.head=e;this.tail=k}o.cache={};o.register=function(e,k){if(e)o.cache[e]=k};o.render=function(e,k,l){l=(new p(l)).head;
o.load(e,l,z.wrap(k)).end()};o.stream=function(e,k){var l=new J;o.nextTick(function(){o.load(e,l.head,z.wrap(k)).end()});return l};o.renderSource=function(e,k,l){return o.compileFn(e)(k,l)};o.compileFn=function(e,k){var l=o.loadSource(o.compile(e,k));return function(x,C){var E=C?new p(C):new J;o.nextTick(function(){l(E.head,z.wrap(x)).end()});return E}};o.load=function(e,k,l){var x=o.cache[e];if(x)return x(k,l);else{if(o.onLoad)return k.map(function(C){o.onLoad(e,function(E,M){if(E)return C.setError(E);
o.cache[e]||o.loadSource(o.compile(M,e));o.cache[e](C,l).end()})});return k.setError(Error("Template Not Found: "+e))}};o.loadSource=function(e){return eval(e)};o.isArray=Array.isArray?Array.isArray:function(e){return Object.prototype.toString.call(e)=="[object Array]"};o.nextTick=function(e){setTimeout(e,0)};o.isEmpty=function(e){if(o.isArray(e)&&!e.length)return true;if(e===0)return false;return!e};o.filter=function(e,k,l){if(l)for(var x=0,C=l.length;x<C;x++){var E=l[x];if(E==="s")k=null;else e=
o.filters[E](e)}if(k)e=o.filters[k](e);return e};o.filters={h:function(e){return o.escapeHtml(e)},j:function(e){return o.escapeJs(e)},u:encodeURI,uc:encodeURIComponent};o.makeBase=function(e){return new z(new H,e)};z.wrap=function(e){if(e instanceof z)return e;return new z(new H(e))};z.prototype.get=function(e){for(var k=this.stack,l;k;){if(k.isObject){l=k.head[e];if(l!==undefined)return l}k=k.tail}return this.global?this.global[e]:undefined};z.prototype.getPath=function(e,k){var l=this.stack,x=k.length;
if(e&&x===0)return l.head;if(l.isObject){l=l.head;for(var C=0;l&&C<x;){l=l[k[C]];C++}return l}};z.prototype.push=function(e,k,l){return new z(new H(e,this.stack,k,l),this.global,this.blocks)};z.prototype.rebase=function(e){return new z(new H(e),this.global,this.blocks)};z.prototype.current=function(){return this.stack.head};z.prototype.getBlock=function(e){var k=this.blocks;if(k)for(var l=k.length,x;l--;)if(x=k[l][e])return x};z.prototype.shiftBlocks=function(e){var k=this.blocks;if(e){newBlocks=
k?k.concat([e]):[e];return new z(this.stack,this.global,newBlocks)}return this};p.prototype.flush=function(){for(var e=this.head;e;){if(e.flushable)this.out+=e.data;else{if(e.error){this.callback(e.error);this.flush=function(){}}return}this.head=e=e.next}this.callback(null,this.out)};J.prototype.flush=function(){for(var e=this.head;e;){if(e.flushable)this.emit("data",e.data);else{if(e.error){this.emit("error",e.error);this.flush=function(){}}return}this.head=e=e.next}this.emit("end")};J.prototype.emit=
function(e,k){var l=this.events;l&&l[e]&&l[e](k)};J.prototype.on=function(e,k){if(!this.events)this.events={};this.events[e]=k;return this};B.prototype.write=function(e){var k=this.taps;if(k)e=k.go(e);this.data+=e;return this};B.prototype.end=function(e){e&&this.write(e);this.flushable=true;this.root.flush();return this};B.prototype.map=function(e){var k=new B(this.root,this.next,this.taps),l=new B(this.root,k,this.taps);this.next=l;this.flushable=true;e(l);return k};B.prototype.tap=function(e){var k=
this.taps;this.taps=k?k.push(e):new r(e);return this};B.prototype.untap=function(){this.taps=this.taps.tail;return this};B.prototype.render=function(e,k){return e(this,k)};B.prototype.reference=function(e,k,l,x){if(typeof e==="function"){e=e(this,k,null,{auto:l,filters:x});if(e instanceof B)return e}return o.isEmpty(e)?this:this.write(o.filter(e,l,x))};B.prototype.section=function(e,k,l,x){if(typeof e==="function"){e=e(this,k,l,x);if(e instanceof B)return e}var C=l.block;l=l["else"];if(x)k=k.push(x);
if(o.isArray(e)){if(C){x=e.length;l=this;for(var E=0;E<x;E++)l=C(l,k.push(e[E],E,x));return l}}else if(e===true){if(C)return C(this,k)}else if(e||e===0){if(C)return C(this,k.push(e))}else if(l)return l(this,k);return this};B.prototype.exists=function(e,k,l){var x=l.block;l=l["else"];if(o.isEmpty(e)){if(l)return l(this,k)}else if(x)return x(this,k);return this};B.prototype.notexists=function(e,k,l){var x=l.block;l=l["else"];if(o.isEmpty(e)){if(x)return x(this,k)}else if(l)return l(this,k);return this};
B.prototype.block=function(e,k,l){l=l.block;if(e)l=e;if(l)return l(this,k);return this};B.prototype.partial=function(e,k){if(typeof e==="function")return this.capture(e,k,function(l,x){o.load(l,x,k).end()});return o.load(e,this,k)};B.prototype.helper=function(e,k,l,x){return o.helpers[e](this,k,l,x)};B.prototype.capture=function(e,k,l){return this.map(function(x){var C=new p(function(E,M){E?x.setError(E):l(M,x)});e(C.head,k).end()})};B.prototype.setError=function(e){this.error=e;this.root.flush();
return this};o.helpers={sep:function(e,k,l){if(k.stack.index===k.stack.of-1)return e;return l.block(e,k)},idx:function(e,k,l){return l.block(e,k.push(k.stack.index))}};r.prototype.push=function(e){return new r(e,this)};r.prototype.go=function(e){for(var k=this;k;){e=k.head(e);k=k.tail}return e};var K=RegExp(/[&<>\"]/),q=/&/g,j=/</g,w=/>/g,t=/\"/g;o.escapeHtml=function(e){if(typeof e==="string"){if(!K.test(e))return e;return e.replace(q,"&amp;").replace(j,"&lt;").replace(w,"&gt;").replace(t,"&quot;")}return e};
var y=/\\/g,A=/\r/g,F=/\u2028/g,L=/\u2029/g,N=/\n/g,V=/\f/g,I=/'/g,Q=/"/g,T=/\t/g;o.escapeJs=function(e){if(typeof e==="string")return e.replace(y,"\\\\").replace(Q,'\\"').replace(I,"\\'").replace(A,"\\r").replace(F,"\\u2028").replace(L,"\\u2029").replace(N,"\\n").replace(V,"\\f").replace(T,"\\t");return e}})(dust);if(typeof exports!=="undefined"){typeof process!=="undefined"&&require("./server")(dust);module.exports=dust}
(function(o){function z(q,j){for(var w=[j[0]],t=1,y=j.length;t<y;t++){var A=o.filterNode(q,j[t]);A&&w.push(A)}return w}function H(q,j){return j}function p(){}function J(q,j){for(var w="",t=1,y=j.length;t<y;t++)w+=o.compileNode(q,j[t]);return w}function B(q,j,w){return"."+w+"("+o.compileNode(q,j[1])+","+o.compileNode(q,j[2])+","+o.compileNode(q,j[4])+","+o.compileNode(q,j[3])+")"}o.compile=function(q,j){var w,t=o.parse(q);w=o.filterNode({},t);t={name:j,bodies:[],blocks:{},index:0,auto:"h"};w="(function(){dust.register("+
(j?'"'+j+'"':"null")+","+o.compileNode(t,w)+");";var y;var A=[],F=t.blocks;for(y in F)A.push(y+":"+F[y]);if(A.length){t.blocks="ctx=ctx.shiftBlocks(blocks);";y="var blocks={"+A.join(",")+"};"}else y=t.blocks="";y=w+y;w=[];A=t.bodies;t=t.blocks;F=0;for(var L=A.length;F<L;F++)w[F]="function body_"+F+"(chk,ctx){"+t+"return chk"+A[F]+";}";t=w.join("");return y+t+"return body_0;})();"};o.filterNode=function(q,j){return o.optimizers[j[0]](q,j)};o.optimizers={body:function(q,j){for(var w=[j[0]],t,y=1,A=
j.length;y<A;y++){var F=o.filterNode(q,j[y]);if(F)if(F[0]==="buffer")if(t)t[1]+=F[1];else{t=F;w.push(F)}else{t=null;w.push(F)}}return w},buffer:H,special:function(q,j){return["buffer",r[j[1]]]},format:p,reference:z,"#":z,"?":z,"^":z,"<":z,"+":z,"@":z,"%":z,partial:z,context:z,params:z,bodies:z,param:z,filters:H,key:H,path:H,literal:H,comment:p};o.pragmas={esc:function(q,j,w){var t=q.auto;j||(j="h");q.auto=j==="s"?"":j;j=J(q,w.block);q.auto=t;return j}};var r={s:" ",n:"\n",r:"\r",lb:"{",rb:"}"};o.compileNode=
function(q,j){return o.nodes[j[0]](q,j)};o.nodes={body:function(q,j){var w=q.index++,t="body_"+w;q.bodies[w]=J(q,j);return t},buffer:function(q,j){return".write("+K(j[1])+")"},format:function(q,j){return".write("+K(j[1]+j[2])+")"},reference:function(q,j){return".reference("+o.compileNode(q,j[1])+",ctx,"+o.compileNode(q,j[2])+")"},"#":function(q,j){return B(q,j,"section")},"?":function(q,j){return B(q,j,"exists")},"^":function(q,j){return B(q,j,"notexists")},"<":function(q,j){for(var w=j[4],t=1,y=
w.length;t<y;t++){var A=w[t];if(A[1][1]==="block"){q.blocks[j[1].text]=o.compileNode(q,A[2]);break}}return""},"+":function(q,j){return".block(ctx.getBlock("+K(j[1].text)+"),"+o.compileNode(q,j[2])+","+o.compileNode(q,j[4])+","+o.compileNode(q,j[3])+")"},"@":function(q,j){return".helper("+K(j[1].text)+","+o.compileNode(q,j[2])+","+o.compileNode(q,j[4])+","+o.compileNode(q,j[3])+")"},"%":function(q,j){var w=j[1][1];if(!o.pragmas[w])return"";for(var t=j[4],y={},A=1,F=t.length;A<F;A++){var L=t[A];y[L[1][1]]=
L[2]}t=j[3];L={};A=1;for(F=t.length;A<F;A++){var N=t[A];L[N[1][1]]=N[2][1]}return o.pragmas[w](q,j[2][1]?j[2][1].text:null,y,L)},partial:function(q,j){return".partial("+o.compileNode(q,j[1])+","+o.compileNode(q,j[2])+")"},context:function(q,j){if(j[1])return"ctx.rebase("+o.compileNode(q,j[1])+")";return"ctx"},params:function(q,j){for(var w=[],t=1,y=j.length;t<y;t++)w.push(o.compileNode(q,j[t]));if(w.length)return"{"+w.join(",")+"}";return"null"},bodies:function(q,j){for(var w=[],t=1,y=j.length;t<
y;t++)w.push(o.compileNode(q,j[t]));return"{"+w.join(",")+"}"},param:function(q,j){return o.compileNode(q,j[1])+":"+o.compileNode(q,j[2])},filters:function(q,j){for(var w=[],t=1,y=j.length;t<y;t++)w.push('"'+j[t]+'"');return'"'+q.auto+'"'+(w.length?",["+w.join(",")+"]":"")},key:function(q,j){return'ctx.get("'+j[1]+'")'},path:function(q,j){for(var w=j[1],t=j[2],y=[],A=0,F=t.length;A<F;A++)y.push('"'+t[A]+'"');return"ctx.getPath("+w+",["+y.join(",")+"])"},literal:function(q,j){return K(j[1])}};var K=
typeof JSON==="undefined"?function(q){return'"'+o.escapeJs(q)+'"'}:JSON.stringify})(typeof exports!=="undefined"?exports:window.dust);
(function(o){var z=function(){var H={parse:function(p){function J(n){var b=n.charCodeAt(0);if(b<255){n="x";var c=2}else{n="u";c=4}n="\\"+n;var d=b.toString(16).toUpperCase();b=d;c=c-d.length;for(d=0;d<c;d++)b="0"+b;return n+b}function B(n){return'"'+n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/[\x80-\uFFFF]/g,J)+'"'}function r(n){if(!(a<R)){if(a>R){R=a;W=[]}W.push(n)}}function K(){var n="body@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=[];for(var c=
q();c!==null;){b.push(c);c=q()}b=b!==null?["body"].concat(b):null;v[n]={nextPos:a,result:b};return b}function q(){var n="part@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=l();if(b!==null)b=b;else{b=j();if(b!==null)b=b;else{b="partial@"+a;var c=v[b];if(c){a=c.nextPos;b=c.result}else{c=h;h=false;var d=a,g=C();if(g!==null){if(p.substr(a,1)===">"){var f=">";a+=1}else{f=null;h&&r('">"')}if(f!==null){var i=I();i=i!==null?["literal",i]:null;if(i!==null)i=i;else{i=Q();i=i!==null?i:null}if(i!==null){var m=
y();if(m!==null){if(p.substr(a,1)==="/"){var s="/";a+=1}else{s=null;h&&r('"/"')}if(s!==null){var u=E();if(u!==null)g=[g,f,i,m,s,u];else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}d=g!==null?["partial",g[2],g[3]]:null;(h=c)&&d===null&&r("partial");v[b]={nextPos:a,result:d};b=d}if(b!==null)b=b;else{b=L();if(b!==null)b=b;else{b=F();if(b!==null)b=b;else{b="buffer@"+a;if(c=v[b]){a=c.nextPos;b=c.result}else{c=h;h=false;d=a;g=M();if(g!==null){f=[];for(i=
U();i!==null;){f.push(i);i=U()}if(f!==null)g=[g,f];else{g=null;a=d}}else{g=null;a=d}d=g!==null?["format",g[0],g[1].join("")]:null;if(d!==null)d=d;else{i=g=a;f=h;h=false;m=x();h=f;if(m===null)f="";else{f=null;a=i}if(f!==null){m=a;i=h;h=false;s=M();h=i;if(s===null)i="";else{i=null;a=m}if(i!==null){m=a;s=h;h=false;u=l();h=s;if(u===null)s="";else{s=null;a=m}if(s!==null){if(p.length>a){m=p.charAt(a);a++}else{m=null;h&&r("any character")}if(m!==null)f=[f,i,s,m];else{f=null;a=g}}else{f=null;a=g}}else{f=
null;a=g}}else{f=null;a=g}g=f!==null?f[3]:null;if(g!==null)for(d=[];g!==null;){d.push(g);i=g=a;f=h;h=false;m=x();h=f;if(m===null)f="";else{f=null;a=i}if(f!==null){m=a;i=h;h=false;s=M();h=i;if(s===null)i="";else{i=null;a=m}if(i!==null){m=a;s=h;h=false;u=l();h=s;if(u===null)s="";else{s=null;a=m}if(s!==null){if(p.length>a){m=p.charAt(a);a++}else{m=null;h&&r("any character")}if(m!==null)f=[f,i,s,m];else{f=null;a=g}}else{f=null;a=g}}else{f=null;a=g}}else{f=null;a=g}g=f!==null?f[3]:null}else d=null;d=d!==
null?["buffer",d.join("")]:null;d=d!==null?d:null}(h=c)&&d===null&&r("buffer");v[b]={nextPos:a,result:d};b=d}b=b!==null?b:null}}}}}v[n]={nextPos:a,result:b};return b}function j(){var n="section@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a,d=w();if(d!==null){var g=E();if(g!==null){var f=K();if(f!==null){var i=A();if(i!==null){var m=t();if(m!==null){var s=d[1].text===m.text?"":null;if(s!==null)d=[d,g,f,i,m,s];else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}}else{d=
null;a=c}}else{d=null;a=c}c=d!==null?function(u,D,O){O.push(["param",["literal","block"],D]);u.push(O);return u}(d[0],d[2],d[3],d[4]):null;if(c!==null)c=c;else{c=a;d=w();if(d!==null){if(p.substr(a,1)==="/"){g="/";a+=1}else{g=null;h&&r('"/"')}if(g!==null){f=E();if(f!==null)d=[d,g,f];else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?function(u){u.push(["bodies"]);return u}(d[0]):null;c=c!==null?c:null}(h=b)&&c===null&&r("section");v[n]={nextPos:a,result:c};return c}function w(){var n="sec_tag_start@"+
a,b=v[n];if(b){a=b.nextPos;return b.result}b=a;var c=C();if(c!==null){if(p.substr(a).match(/^[#?^<+@%]/)!==null){var d=p.charAt(a);a++}else{d=null;h&&r("[#?^<+@%]")}if(d!==null){var g=N();if(g!==null){var f=y();if(f!==null){var i;i="params@"+a;var m=v[i];if(m){a=m.nextPos;i=m.result}else{m=h;h=false;var s=[],u=a,D=U();if(D!==null){var O=I();if(O!==null){if(p.substr(a,1)==="="){var P="=";a+=1}else{P=null;h&&r('"="')}if(P!==null){var G=N();if(G!==null)G=G;else{G=Q();G=G!==null?G:null}if(G!==null)D=
[D,O,P,G];else{D=null;a=u}}else{D=null;a=u}}else{D=null;a=u}}else{D=null;a=u}for(u=D!==null?["param",["literal",D[1]],D[3]]:null;u!==null;){s.push(u);u=a;D=U();if(D!==null){O=I();if(O!==null){if(p.substr(a,1)==="="){P="=";a+=1}else{P=null;h&&r('"="')}if(P!==null){G=N();if(G!==null)G=G;else{G=Q();G=G!==null?G:null}if(G!==null)D=[D,O,P,G];else{D=null;a=u}}else{D=null;a=u}}else{D=null;a=u}}else{D=null;a=u}u=D!==null?["param",["literal",D[1]],D[3]]:null}s=s!==null?["params"].concat(s):null;(h=m)&&s===
null&&r("params");v[i]={nextPos:a,result:s};i=s}if(i!==null)c=[c,d,g,f,i];else{c=null;a=b}}else{c=null;a=b}}else{c=null;a=b}}else{c=null;a=b}}else{c=null;a=b}b=c!==null?[c[1],c[2],c[3],c[4]]:null;v[n]={nextPos:a,result:b};return b}function t(){var n="end_tag@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a,d=C();if(d!==null){if(p.substr(a,1)==="/"){var g="/";a+=1}else{g=null;h&&r('"/"')}if(g!==null){var f=N();if(f!==null){var i=E();if(i!==null)d=[d,g,f,i];else{d=null;a=c}}else{d=null;
a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?d[2]:null;(h=b)&&c===null&&r("end tag");v[n]={nextPos:a,result:c};return c}function y(){var n="context@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=a;if(p.substr(a,1)===":"){var c=":";a+=1}else{c=null;h&&r('":"')}if(c!==null){var d=N();if(d!==null)c=[c,d];else{c=null;a=b}}else{c=null;a=b}b=c!==null?c[1]:null;b=b!==null?b:"";b=b!==null?b?["context",b]:["context"]:null;v[n]={nextPos:a,result:b};return b}function A(){var n="bodies@"+a,b=v[n];if(b){a=
b.nextPos;return b.result}b=h;h=false;var c=[],d=a,g=C();if(g!==null){if(p.substr(a,1)===":"){var f=":";a+=1}else{f=null;h&&r('":"')}if(f!==null){var i=I();if(i!==null){var m=E();if(m!==null){var s=K();if(s!==null)g=[g,f,i,m,s];else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}for(d=g!==null?["param",["literal",g[2]],g[4]]:null;d!==null;){c.push(d);d=a;g=C();if(g!==null){if(p.substr(a,1)===":"){f=":";a+=1}else{f=null;h&&r('":"')}if(f!==null){i=I();if(i!==null){m=
E();if(m!==null){s=K();if(s!==null)g=[g,f,i,m,s];else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}}else{g=null;a=d}d=g!==null?["param",["literal",g[2]],g[4]]:null}c=c!==null?["bodies"].concat(c):null;(h=b)&&c===null&&r("bodies");v[n]={nextPos:a,result:c};return c}function F(){var n="reference@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a,d=C();if(d!==null){var g=N();if(g!==null){var f;f="filters@"+a;var i=v[f];if(i){a=i.nextPos;f=i.result}else{i=h;h=false;var m=
[],s=a;if(p.substr(a,1)==="|"){var u="|";a+=1}else{u=null;h&&r('"|"')}if(u!==null){var D=I();if(D!==null)u=[u,D];else{u=null;a=s}}else{u=null;a=s}for(s=u!==null?u[1]:null;s!==null;){m.push(s);s=a;if(p.substr(a,1)==="|"){u="|";a+=1}else{u=null;h&&r('"|"')}if(u!==null){D=I();if(D!==null)u=[u,D];else{u=null;a=s}}else{u=null;a=s}s=u!==null?u[1]:null}m=m!==null?["filters"].concat(m):null;(h=i)&&m===null&&r("filters");v[f]={nextPos:a,result:m};f=m}if(f!==null){i=E();if(i!==null)d=[d,g,f,i];else{d=null;
a=c}}else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?["reference",d[1],d[2]]:null;(h=b)&&c===null&&r("reference");v[n]={nextPos:a,result:c};return c}function L(){var n="special@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a,d=C();if(d!==null){if(p.substr(a,1)==="~"){var g="~";a+=1}else{g=null;h&&r('"~"')}if(g!==null){var f=I();if(f!==null){var i=E();if(i!==null)d=[d,g,f,i];else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?["special",d[2]]:
null;(h=b)&&c===null&&r("special");v[n]={nextPos:a,result:c};return c}function N(){var n="identifier@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=V();c=c!==null?X(["path"].concat(c),n):null;if(c!==null)c=c;else{c=I();c=c!==null?X(["key",c],n):null;c=c!==null?c:null}(h=b)&&c===null&&r("identifier");v[n]={nextPos:a,result:c};return c}function V(){var n="path@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a,d=I();d=d!==null?d:"";if(d!==null){var g=a;if(p.substr(a,1)===
"."){var f=".";a+=1}else{f=null;h&&r('"."')}if(f!==null){var i=I();if(i!==null)f=[f,i];else{f=null;a=g}}else{f=null;a=g}g=f!==null?f[1]:null;if(g!==null)for(var m=[];g!==null;){m.push(g);g=a;if(p.substr(a,1)==="."){f=".";a+=1}else{f=null;h&&r('"."')}if(f!==null){i=I();if(i!==null)f=[f,i];else{f=null;a=g}}else{f=null;a=g}g=f!==null?f[1]:null}else m=null;if(m!==null)d=[d,m];else{d=null;a=c}}else{d=null;a=c}c=d!==null?function(s,u){if(s){u.unshift(s);return[false,u]}return[true,u]}(d[0],d[1]):null;if(c!==
null)c=c;else{if(p.substr(a,1)==="."){c=".";a+=1}else{c=null;h&&r('"."')}c=c!==null?[true,[]]:null;c=c!==null?c:null}(h=b)&&c===null&&r("path");v[n]={nextPos:a,result:c};return c}function I(){var n="key@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a;if(p.substr(a).match(/^[a-zA-Z_$]/)!==null){var d=p.charAt(a);a++}else{d=null;h&&r("[a-zA-Z_$]")}if(d!==null){var g=[];if(p.substr(a).match(/^[0-9a-zA-Z_$]/)!==null){var f=p.charAt(a);a++}else{f=null;h&&r("[0-9a-zA-Z_$]")}for(;f!==null;){g.push(f);
if(p.substr(a).match(/^[0-9a-zA-Z_$]/)!==null){f=p.charAt(a);a++}else{f=null;h&&r("[0-9a-zA-Z_$]")}}if(g!==null)d=[d,g];else{d=null;a=c}}else{d=null;a=c}c=d!==null?d[0]+d[1].join(""):null;(h=b)&&c===null&&r("key");v[n]={nextPos:a,result:c};return c}function Q(){var n="inline@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a;if(p.substr(a,1)==='"'){var d='"';a+=1}else{d=null;h&&r('"\\""')}if(d!==null){if(p.substr(a,1)==='"'){var g='"';a+=1}else{g=null;h&&r('"\\""')}if(g!==null)d=[d,
g];else{d=null;a=c}}else{d=null;a=c}c=d!==null?["literal",""]:null;if(c!==null)c=c;else{c=a;if(p.substr(a,1)==='"'){d='"';a+=1}else{d=null;h&&r('"\\""')}if(d!==null){g=e();if(g!==null){if(p.substr(a,1)==='"'){var f='"';a+=1}else{f=null;h&&r('"\\""')}if(f!==null)d=[d,g,f];else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?["literal",d[1]]:null;if(c!==null)c=c;else{c=a;if(p.substr(a,1)==='"'){d='"';a+=1}else{d=null;h&&r('"\\""')}if(d!==null){f=T();if(f!==null)for(g=[];f!==null;){g.push(f);
f=T()}else g=null;if(g!==null){if(p.substr(a,1)==='"'){f='"';a+=1}else{f=null;h&&r('"\\""')}if(f!==null)d=[d,g,f];else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?["body"].concat(d[1]):null;c=c!==null?c:null}}(h=b)&&c===null&&r("inline");v[n]={nextPos:a,result:c};return c}function T(){var n="inline_part@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=L();if(b!==null)b=b;else{b=F();if(b!==null)b=b;else{b=e();b=b!==null?["buffer",b]:null;b=b!==null?b:null}}v[n]={nextPos:a,result:b};return b}
function e(){var n="literal@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a,d=a,g=h;h=false;var f=x();h=g;if(f===null)g="";else{g=null;a=d}if(g!==null){f=a;d=h;h=false;var i=M();h=d;if(i===null)d="";else{d=null;a=f}if(d!==null){f=k();if(f!==null)f=f;else{if(p.substr(a).match(/^[^"]/)!==null){f=p.charAt(a);a++}else{f=null;h&&r('[^"]')}f=f!==null?f:null}if(f!==null)g=[g,d,f];else{g=null;a=c}}else{g=null;a=c}}else{g=null;a=c}c=g!==null?g[2]:null;if(c!==null)for(var m=[];c!==null;){m.push(c);
d=c=a;g=h;h=false;f=x();h=g;if(f===null)g="";else{g=null;a=d}if(g!==null){f=a;d=h;h=false;i=M();h=d;if(i===null)d="";else{d=null;a=f}if(d!==null){f=k();if(f!==null)f=f;else{if(p.substr(a).match(/^[^"]/)!==null){f=p.charAt(a);a++}else{f=null;h&&r('[^"]')}f=f!==null?f:null}if(f!==null)g=[g,d,f];else{g=null;a=c}}else{g=null;a=c}}else{g=null;a=c}c=g!==null?g[2]:null}else m=null;m=m!==null?m.join(""):null;(h=b)&&m===null&&r("literal");v[n]={nextPos:a,result:m};return m}function k(){var n="esc@"+a,b=v[n];
if(b){a=b.nextPos;return b.result}if(p.substr(a,2)==='\\"'){b='\\"';a+=2}else{b=null;h&&r('"\\\\\\""')}b=b!==null?'"':null;v[n]={nextPos:a,result:b};return b}function l(){var n="comment@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=h;h=false;var c=a;if(p.substr(a,2)==="{!"){var d="{!";a+=2}else{d=null;h&&r('"{!"')}if(d!==null){var g=[],f=a,i=a,m=h;h=false;if(p.substr(a,2)==="!}"){var s="!}";a+=2}else{s=null;h&&r('"!}"')}h=m;if(s===null)m="";else{m=null;a=i}if(m!==null){if(p.length>a){i=p.charAt(a);
a++}else{i=null;h&&r("any character")}if(i!==null)i=[m,i];else{i=null;a=f}}else{i=null;a=f}for(f=i!==null?i[1]:null;f!==null;){g.push(f);i=f=a;m=h;h=false;if(p.substr(a,2)==="!}"){s="!}";a+=2}else{s=null;h&&r('"!}"')}h=m;if(s===null)m="";else{m=null;a=i}if(m!==null){if(p.length>a){i=p.charAt(a);a++}else{i=null;h&&r("any character")}if(i!==null)i=[m,i];else{i=null;a=f}}else{i=null;a=f}f=i!==null?i[1]:null}if(g!==null){if(p.substr(a,2)==="!}"){f="!}";a+=2}else{f=null;h&&r('"!}"')}if(f!==null)d=[d,g,
f];else{d=null;a=c}}else{d=null;a=c}}else{d=null;a=c}c=d!==null?["comment",d[1].join("")]:null;(h=b)&&c===null&&r("comment");v[n]={nextPos:a,result:c};return c}function x(){var n="tag@"+a,b=v[n];if(b){a=b.nextPos;return b.result}b=a;var c=C();if(c!==null){if(p.substr(a).match(/^[#?^><+%:@\/~%]/)!==null){var d=p.charAt(a);a++}else{d=null;h&&r("[#?^><+%:@\\/~%]")}if(d!==null){var g=a,f=a,i=h;h=false;var m=E();h=i;if(m===null)i="";else{i=null;a=f}if(i!==null){f=a;m=h;h=false;var s=M();h=m;if(s===null)m=
"";else{m=null;a=f}if(m!==null){if(p.length>a){f=p.charAt(a);a++}else{f=null;h&&r("any character")}if(f!==null)i=[i,m,f];else{i=null;a=g}}else{i=null;a=g}}else{i=null;a=g}if(i!==null)for(var u=[];i!==null;){u.push(i);f=g=a;i=h;h=false;m=E();h=i;if(m===null)i="";else{i=null;a=f}if(i!==null){f=a;m=h;h=false;s=M();h=m;if(s===null)m="";else{m=null;a=f}if(m!==null){if(p.length>a){f=p.charAt(a);a++}else{f=null;h&&r("any character")}if(f!==null)i=[i,m,f];else{i=null;a=g}}else{i=null;a=g}}else{i=null;a=g}}else u=
null;if(u!==null){g=E();if(g!==null)c=[c,d,u,g];else{c=null;a=b}}else{c=null;a=b}}else{c=null;a=b}}else{c=null;a=b}if(c!==null)b=c;else{b=F();b=b!==null?b:null}v[n]={nextPos:a,result:b};return b}function C(){var n="ld@"+a,b=v[n];if(b){a=b.nextPos;return b.result}if(p.substr(a,1)==="{"){b="{";a+=1}else{b=null;h&&r('"{"')}v[n]={nextPos:a,result:b};return b}function E(){var n="rd@"+a,b=v[n];if(b){a=b.nextPos;return b.result}if(p.substr(a,1)==="}"){b="}";a+=1}else{b=null;h&&r('"}"')}v[n]={nextPos:a,result:b};
return b}function M(){var n="eol@"+a,b=v[n];if(b){a=b.nextPos;return b.result}if(p.substr(a,1)==="\n"){b="\n";a+=1}else{b=null;h&&r('"\\n"')}if(b!==null)b=b;else{if(p.substr(a,2)==="\r\n"){b="\r\n";a+=2}else{b=null;h&&r('"\\r\\n"')}if(b!==null)b=b;else{if(p.substr(a,1)==="\r"){b="\r";a+=1}else{b=null;h&&r('"\\r"')}if(b!==null)b=b;else{if(p.substr(a,1)==="\u2028"){b="\u2028";a+=1}else{b=null;h&&r('"\\u2028"')}if(b!==null)b=b;else{if(p.substr(a,1)==="\u2029"){b="\u2029";a+=1}else{b=null;h&&r('"\\u2029"')}b=
b!==null?b:null}}}}v[n]={nextPos:a,result:b};return b}function U(){var n="ws@"+a,b=v[n];if(b){a=b.nextPos;return b.result}if(p.substr(a).match(/^[\t\u000b\u000c \xA0\uFEFF]/)!==null){b=p.charAt(a);a++}else{b=null;h&&r("[\t\u000b\u000c \\xA0\\uFEFF]")}v[n]={nextPos:a,result:b};return b}function Y(){var n=function(c){c.sort();for(var d=null,g=[],f=0;f<c.length;f++)if(c[f]!==d){g.push(c[f]);d=c[f]}switch(g.length){case 0:return"end of input";case 1:return g[0];default:return g.slice(0,g.length-1).join(", ")+
" or "+g[g.length-1]}}(W),b=Math.max(a,R);b=b<p.length?B(p.charAt(b)):"end of input";return"Expected "+n+" but "+b+" found."}function Z(){for(var n=1,b=1,c=false,d=0;d<R;d++){var g=p.charAt(d);if(g==="\n"){c||n++;b=1;c=false}else if(g==="\r"|g==="\u2028"||g==="\u2029"){n++;b=1;c=true}else{b++;c=false}}return{line:n,column:b}}function X(n,b){n.text=p.substring(b.split("@")[1],a);return n}var a=0,h=true,R=0,W=[],v={},S=K();if(S===null||a!==p.length){S=Z();throw new SyntaxError(Y(),S.line,S.column);
}return S},toSource:function(){return this._source}};H.SyntaxError=function(p,J,B){this.name="SyntaxError";this.message=p;this.line=J;this.column=B};H.SyntaxError.prototype=Error.prototype;return H}();o.parse=z.parse})(typeof exports!=="undefined"?exports:window.dust);

14
node_modules/dust/docs/about.md generated vendored
View File

@ -1,14 +0,0 @@
Why Dust? Why another templating engine when there are so many alternatives? Dust is based on the philosophy that an ideal templating environment should be:
+ __Markup-like__: _A templating syntax should not encompass operations that are better left to a programming language_. Templates should make it easy to format content for presentation while keeping application logic where it belongs: in the application.
+ __Asynchronous__: Template helpers should be callable _asynchronously_ and in _parallel_ so that expensive operations (caching, deferred loading, filtering) can run as the template is being rendered.
+ __Streaming__: Templates should allow (but not require) data to be flushed to the output in user-defined chunks.
+ __Browser and server compatible__: Templates should render in both server and browser environments without hacks or extensive configuration.
+ __Storage agnostic__: _The templating engine should not impose a particular loading scheme_. Developers should be free to load templates via the filesystem, a database or an army of carrier pigeons.
+ __Composable__: Designers should be able to break presentation markup into manageable components and combine these components at runtime. _It should not be necessary to statically link templates or manually assemble 'layouts' inside application code._
+ __Format agnostic__: While HTML generation and DOM manipulation are useful in specific instances, a general-purpose template system should not be tied to a particular output format.
+ __Precise__: The parser should be accurate enough that designers rarely have to use escape sequences to achieve the desired result. Similarly, templates shouldn't mysteriously generate or eliminate whitespace.
+ __Safe(r)__: At the very least, the engine should be configurable such that it is reasonably safe to render untrusted templates in a server environment.
+ __Fast__: Server-side templates cannot always be cached. Browser-side templates may be rendered on devices with limited system resources. _A template engine should be fast enough to render in real time without bottlenecking its environment_.
If this list leaves you nodding your head in agreement you should [give Dust a try](http://akdubya.github.com/dustjs).

310
node_modules/dust/docs/api.md generated vendored
View File

@ -1,310 +0,0 @@
A pure JavaScript library, Dust is runs in both browser-side and server-side environments. Dust templates are compiled and then loaded where they are needed along with the runtime library. The library doesn't make any assumptions about how templates are loaded; you are free to integrate templating into your environment as you see fit.
### Installation
To run Dust within Node.js, first install via [npm](http://github.com/isaacs/npm):
npm install dust
Then, within your Node script or the REPL:
var dust = require('dust');
This will import everything needed to parse, compile and render templates. To render Dust templates in the browser, grab the runtime distribution and include it in your script tags along with your compiled templates:
<script src="dust-core-0.3.0.min.js"></script>
<script src="compiled_templates.js"></script>
Include the full distribution if you want to compile templates within the browser (as in the online demo):
<script src="dust-full-0.3.0.min.js"></script>
Precompilation is the recommended approach for general use.
### Compiling Templates
Use `dust.compile` to compile a template body into a string of JavaScript source code:
var compiled = dust.compile("Hello {name}!", "intro");
The variable `compiled` now contains the following string:
'(function(){dust.register("intro",body_0) ...'
If you save this source to a file and include the file in your HTML script tags, the compiled template will automatically register itself with the local runtime, under the name "intro". To evaluate a compiled template string manually, use `dust.loadSource`:
dust.loadSource(compiled);
The template is now available within the `dust.cache` object.
### Rendering Templates
The rendering engine provides both callback and streaming interfaces.
#### The Callback Interface
To render a template, call `dust.render` with the template name, a context object and a callback function:
dust.render("intro", {name: "Fred"}, function(err, out) {
console.log(out);
});
The code above will write the following to the console:
Hello Fred!
#### The Streaming Interface
Templates may also be streamed. `dust.stream` returns a handler very similar to a Node `EventEmitter`:
dust.stream("index", context)
.on("data", function(data) {
console.log(data);
})
.on("end", function() {
console.log("I'm finished!");
})
.on("error", function(err) {
console.log("Something terrible happened!");
});
When used with specially crafted context handlers, the streaming interface provides chunked template rendering.
### Contexts
The context is a special object that handles variable lookups and controls template behavior. It is the interface between your application logic and your templates. The context can be visualized as a stack of objects that grows as we descend into nested sections:
global --> { helper: function() { ... }, ... }
root --> { profile: { ... }, ... }
profile --> { friends: [ ... ], ... }
friends[0] --> { name: "Jorge", ... }
When looking up a key, Dust searches the context stack from the bottom up. There is no need to merge helper functions into the template data; instead, create a base context onto which you can push your local template data:
// Set up a base context with global helpers
var base = dust.makeBase({
sayHello: function() { return "Hello!" }
});
// Push to the base context at render time
dust.render("index", base.push({foo: "bar"}), function(err, out) {
console.log(out);
});
Dust does not care how your reference objects are built. You may, for example, push prototyped objects onto the stack. The system leaves the `this` keyword intact when calling handler functions on your objects.
### Handlers
When Dust encounters a function in the context, it calls the function, passing in arguments that reflect the current state of the template. In the simplest case, a handler can pass a value back to the template engine:
{
name: function() {
return "Bob";
}
}
#### Chunks
But handlers can do much more than return values: they have complete control over the flow of the template, using the same API Dust uses internally. For example, the handler below writes a string directly to the current template chunk:
{
name: function(chunk) {
return chunk.write("Bob");
}
}
A `Chunk` is a Dust primitive for controlling the flow of the template. Depending upon the behaviors defined in the context, templates may output one or more chunks during rendering. A handler that writes to a chunk directly must return the modified chunk.
#### Accessing the Context
Handlers have access to the context object:
{
wrap: function(chunk, context) {
return chunk.write(context.get("foo"));
}
}
`context.get("foo")` searches for _foo_ within the context stack. `context.current()` retrieves the value most recently pushed onto the context stack.
#### Accessing Body Parameters
The `bodies` object provides access to any bodies defined within the calling block.
{#guide}foo{:else}bar{/guide}
The template above will either render "foo" or "bar" depending on the behavior of the handler below:
{
guide: function(chunk, context, bodies) {
if (secret === 42) {
return chunk.render(bodies.block, context);
} else {
return chunk.render(bodies['else'], context);
}
}
}
`bodies.block` is a special parameter that returns the default (unnamed) block. `chunk.render` renders the chosen block.
#### Accessing Inline Parameters
The `params` object contains any inline parameters passed to a section tag:
{
hello: function(chunk, context, bodies, params) {
if (params.greet === "true") {
return chunk.write("Hello!");
}
return chunk;
}
}
#### Asynchronous Handlers
You may define handlers that execute asynchronously and in parallel:
{
type: function(chunk) {
return chunk.map(function(chunk) {
setTimeout(function() {
chunk.end("Async");
});
});
}
}
`chunk.map` tells Dust to manufacture a new chunk, reserving a slot in the output stream before continuing on to render the rest of the template. You must (eventually) call `chunk.end()` on a mapped chunk to weave its content back into the stream.
`chunk.map` provides a convenient way to split up templates rendered via `dust.stream`. For example, you might wrap the head of an HTML document in a special `{#head} ... {/head}` tag that is flushed to the browser before the rest of the body has finished rendering.
### Reference
#### Compiling
dust.compile(source, name)
Compiles `source` into a JavaScript template string. Registers itself under `name` when evaluated.
dust.compileFn(source, [name])
Compiles `source` directly into a JavaScript function that takes a context and an optional callback (see `dust.renderSource`). Registers the template under `name` if this argument is supplied.
dust.optimizers
Object containing functions that transform the parse-tree before the template is compiled. To disable whitespace compression:
dust.optimizers.format = function(ctx, node) { return node };
#### Loading
dust.register(name, fn)
Used internally to register template function `fn` with the runtime environment. Override to customize the way Dust caches templates.
dust.onLoad(name, callback(err, out))
By default Dust returns a "template not found" error when a named template cannot be located in the cache. Override `onLoad` to specify a fallback loading mechanism (e.g., to load templates from the filesystem or a database).
dust.loadSource(source, [filename])
Evaluates compiled `source` string. In Node.js, evaluates `source` as if it were loaded from `filename`. `filename` is optional.
#### Rendering
dust.render(name, context, callback(error, output))
Renders the named template and calls `callback` on completion. `context` may be a plain object or an instance of `dust.Context`.
dust.stream(name, context)
Streams the named template. `context` may be a plain object or an instance of `dust.Context`. Returns an instance of `dust.Stream`.
stream.on("data", listener(data))
stream.on("end", listener)
stream.on("error", listener(error))
Registers an event listener. Streams accept a single listener for a given event.
dust.renderSource(source, context, [callback(error, output)])
Compiles and renders `source`, invoking `callback` on completion. If no callback is supplied this function returns a Stream object. Use this function when precompilation is not required.
#### Contexts
dust.makeBase(object)
Manufactures a `dust.Context` instance with its global object set to `object`.
context.get(key)
Retrieves the value at `key` from the context stack.
context.push(head, [index], [length])
Pushes an arbitrary value onto the context stack and returns a new context instance. Specify `index` and/or `length` to enable enumeration helpers.
context.rebase(head)
Returns a new context instance consisting only of the value at `head`, plus any previously defined global object.
context.current()
Returns the `head` of the context stack.
#### Chunks
The operations below always return a chunk object.
chunk.write(data)
Writes `data` to this chunk's buffer.
chunk.map(callback(chunk))
Creates a new chunk and passes it to `callback`. Use `map` to wrap asynchronous functions and to partition the template for streaming.
chunk.end(data)
Writes `data` to this chunk's buffer and marks it as flushable. This method _must_ be called on any chunks created via `chunk.map`. Do _not_ call this method on a handler's main chunk -- `dust.render` and `dust.stream` take care of this for you.
chunk.tap(callback)
chunk.untap()
Convenience methods for applying filters to a stream. See the _filter_ demo for an example.
chunk.render(body, context)
Renders a template block, such as a default block or an `else` block. Basically equivalent to `body(chunk, context)`.
chunk.setError(error)
Sets an error on this chunk and immediately flushes the output.
chunk.reference(elem, context, auto, filters)
chunk.section(elem, context, bodies, params)
chunk.exists(elem, context, bodies)
chunk.notexists(elem, context, bodies)
chunk.block(elem, context, bodies)
chunk.partial(elem, context)
chunk.helper(name, context, bodies, params)
These methods implement Dust's default behavior for keys, sections, blocks, partials and context helpers. While it is unlikely you'll need to modify these methods or invoke them from within handlers, the source code may be a useful point of reference for developers.
#### Utilities
dust.filters
Object containing built-in key filters. Can be customized with additional filters.
dust.helpers
Object containing the built-in context helpers. These may also be customized.
dust.escapeHtml
HTML escape function used by `dust.filters.h`.
dust.escapeJs
JavaScript string escape function used by `dust.filters.j`.

68
node_modules/dust/docs/build.js generated vendored
View File

@ -1,68 +0,0 @@
var path = require('path'),
fs = require('fs'),
Script = process.binding('evals').Script,
dust = require('../lib/dust'),
root = path.join(path.dirname(__filename), "..");
var src = fs.readFileSync(path.join(root, 'docs/index.dust.html'), 'utf8');
dust.loadSource(dust.compile(src, "index"));
var sd = process.compile(fs.readFileSync(path.join(root, 'vendor/showdown.js'), 'utf8'), 'showdown.js');
var inliners = {
css: function(names) {
var out = "<style type=\"text/css\">";
names.forEach(function(name) {
out += fs.readFileSync(path.join(root, 'docs', name + '.css'), 'utf8');
});
out += "</style>";
return out;
},
js: function(names) {
var out = "<script type=\"text/javascript\">";
names.forEach(function(name) {
out += fs.readFileSync(path.join(root, 'docs', name + '.js'), 'utf8');
});
out += "</script>";
return out;
}
}
var context = {
inline: function(chk, ctx, bod, prm) {
var names = prm.names.split(' ');
return chk.write(inliners[prm.ext](names));
},
tmpl: function(chk, ctx, bod, prm) {
var names = prm.names.split(' ');
var out = "<script type=\"text/javascript\">";
names.forEach(function(name) {
out += dust.compile(fs.readFileSync(path.join(root, 'docs', name + '.dust.html'), 'utf8'), "select");
});
out += "</script>";
return chk.write(out);
},
md: function(chk, ctx, bod, prm) {
var converter = new sd();
return chk.tap(function(data) {
return converter.makeHtml(data);
}).render(bod.block, ctx).untap();
},
file: function(chk, ctx, bod, prm) {
var name = prm.name;
return chk.write(fs.readFileSync(path.join(root, 'docs', name), 'utf8'));
}
}
function render() {
dust.render("index", context, function(err, output) {
if (err) throw err;
fs.writeFileSync(path.join(root, 'index.html'), output);
});
}
render();

203
node_modules/dust/docs/index.css generated vendored
View File

@ -1,203 +0,0 @@
body {
font-family: 'Georgia', serif;
font-size: 18px;
margin: 0;
padding: 0;
}
p, h4, h3, .content ul {
line-height: 26px;
margin-top: 26px;
margin-bottom: 26px;
}
.content ul li {
margin-top: 13px;
margin-bottom: 13px;
}
h1, h2 {
line-height: 48px;
font-size: 32px;
font-weight: normal;
margin: 8px 0 8px 2%;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 1em;
}
h1, h2, pre, code, .console, .status, #nav, #tagline {
font-family: 'Droid Sans Mono', 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace;
}
a:link, a:visited {
color: #ef674a;
}
p code {
font-size: 16px;
line-height: 16px;
}
pre, .console {
background-color: #191919;
white-space: pre-wrap;
word-wrap: break-word;
}
.console {
font-size: 16px;
height: 270px;
color: #dddddd;
margin-top: 26px;
margin-bottom: 26px;
border: 1px solid #888;
resize: auto;
overflow: auto;
padding: 2px;
}
textarea {
width: 100%;
display: block;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
#nav {
position: fixed;
top: 18px;
right: 2%;
font-size: 22px;
z-index: 99;
}
#nav a:link, #nav a:visited {
color: #eaf2d9;
}
#nav a {
text-decoration: none;
margin-left: 17px;
}
#nav a:last {
margin: 0;
}
#tagline {
position: absolute;
display: none;
top: 24px;
font-size: 14px;
}
#guide pre {
font-size: 16px;
line-height: 26px;
color: #dddddd;
padding: 26px;
margin: 26px 0;
}
#header, #demo {
clear: both;
}
.ok {
background-color: green;
}
.error {
background-color: red;
}
.pending {
background-color: yellow;
}
.status {
font-size: 14px;
padding: 2px;
margin-top: -24px;
}
.header, .content {
clear: both;
width: 100%;
overflow: hidden;
color: #ede6da;
}
.header {
clear: both;
width: 100%;
-webkit-box-shadow: 0px 4px 6px hsla(0, 0%, 0%, 0.4);
-moz-box-shadow: 0px 4px 6px hsla(0, 0%, 0%, 0.4);
background-color: #581406;
}
.content {
background-color: #2d2929;
}
.left {
float: left;
width: 100%;
position: relative;
-webkit-box-shadow: 2px 0px 6px hsla(0, 0%, 0%, 0.4);
-moz-box-shadow: 2px 0px 6px hsla(0, 0%, 0%, 0.4);
}
.content .left, .header .left {
right: 50%;
}
.content .left {
background-color: #272121;
}
.header, .col1, .col2 {
float: left;
position: relative;
overflow: hidden;
}
.col1 {
width: 96%;
left: 2%;
}
.left .header {
width: 100%;
left: 50%;
}
.left .col1 {
width: 46%;
left: 52%;
}
.left .col2 {
width: 46%;
left: 56%;
}
.docked {
position: fixed;
width: 100%;
top: 0;
background-color: hsla(10, 87%, 18%, 0.80);
z-index: 5;
}
code .keyword { font-weight: bold; color: #dd7522 }
code .string, code .regexp { color: #669933 }
code .class, code .special { }
code .number { color: #eddd3d }
code .comment { color: grey }

View File

@ -1,95 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>dust</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono:regular&subset=latin" rel="stylesheet" type="text/css">
{#inline names="index" ext="css"/}
<script src="vendor/ecma.js"></script>
<script src="vendor/jquery.min.js"></script>
<script src="vendor/jsdump.js"></script>
<script src="vendor/beautify.js"></script>
<script src="lib/dust.js"></script>
<script src="lib/parser.js"></script>
<script src="lib/compiler.js"></script>
<script src="test/examples.js"></script>
<script src="test/uutest.js"></script>
<script src="test/core.js"></script>
{#tmpl names="select"/}
{#inline names="index" ext="js"/}
</head>
<body>
<div id="dust" class="content">
<div class="left">
<div class="header">
<h1>{~lb}dust{~rb}</h1>
<span id="tagline">asynchronous streaming templates for the browser and node.js</span>
</div>
<div id="nav">
<a href="#dust">home</a>
<a href="#guide">guide</a>
<a href="#tests">tests</a>
<a href="#about">about</a>
<a href="http://github.com/akdubya/dustjs">code</a>
</div>
<div class="col1">
<p>1. Select a template <span id="select"></span> or write your own:</p>
<textarea id="input-source" class="console"></textarea>
<div class="status ok">Ready</div>
<p>2. The compiled template registers itself by name:</p>
<pre class="console"><code id="output-js"></code></pre>
<p>When you're done messing around have a look at the guide.</p>
</div>
<div class="col2">
<p>3. Control template behavior with contexts and helpers:</p>
<textarea id="input-context" class="console"></textarea>
<div class="status ok">Ready</div>
<p>4. Render or stream the result:</p>
<pre id="output-text" class="console"></pre>
</div>
</div>
</div>
<div id="guide" class="content">
<div class="left">
<div class="header">
<h2>{~lb}guide{~rb}</h2>
</div>
<div id="syntax" class="col1">
{#md}{#file name="syntax.md"/}{/md}
</div>
<div id="api" class="col2">
{#md}{#file name="api.md"/}{/md}
</div>
</div>
</div>
<div id="tests" class="content">
<div class="left">
<div class="header">
<h2>{~lb}tests{~rb}</h2>
</div>
<div class="col1">
<p>If the console below indicates an error then we have a problem.</p>
<pre id="test-console" class="console"></pre>
</div>
<div class="col2">
<p>Interested in seeing how Dust stacks up against similar templating engines? Have a look at the <a href="benchmark/index.html">live benchmarks</a>.</p>
</div>
</div>
</div>
<div id="about" class="content">
<div class="left">
<div class="header">
<h2>{~lb}about{~rb}</h2>
</div>
<div class="col1">
{#md}{#file name="about.md"/}{/md}
</div>
<div class="col2">
<p>Dust was created by <a href="http://github.com/akdubya">akdubya</a>.</p>
<p>This page is powered by Dust, <a href="http://jquery.com/">jQuery</a>, <a href="http://attacklab.net/showdown/">showdown</a>, <a href="http://jsbeautifier.org/">beautify.js</a>, <a href="http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html">jsDump</a> and <a href="http://github.com/cloudhead/hijs">hijs</a>.
</div>
</div>
</div>
<script src="vendor/hijs.js"></script>
</body>
</html>

181
node_modules/dust/docs/index.js generated vendored
View File

@ -1,181 +0,0 @@
jsDump.parsers['function'] = function(fn) {
return fn.toString();
}
function renderDemo() {
var tmpl = dust.cache["demo"],
source = $('#input-context').val();
$('#output-text').empty();
if (tmpl && source) {
setPending('#input-context');
setPending('#output-text');
try {
eval("var context = " + source + ";");
if (typeof context === 'function') {
context = context();
}
dust.stream("demo", context)
.on('data', function(data) {
$('#output-text').append(dust.escapeHtml(data));
})
.on('end', function() {
setOkay('#input-context');
setOkay('#output-text');
})
.on('error', function(err) {
setError('#input-context', err);
});
} catch(err) {
setError('#input-context', err);
}
}
}
function setOkay(sel) {
$(sel).next()
.removeClass('pending')
.addClass('ok')
.html('Ready');
}
function setPending(sel) {
$(sel).next()
.removeClass('ok')
.removeClass('error')
.addClass('pending')
.html('Pending');
}
function setError(sel, err) {
$(sel).next()
.removeClass('pending')
.addClass('error')
.html(err.toString());
}
function dump(obj) {
return js_beautify(jsDump.parse(obj), {
indent_size: 2
});
}
function runSuite() {
var suite = new uutest.Suite({
start: function() {
$('#test-console').empty();
},
pass: function() {
$('#test-console').append(".");
},
fail: function() {
$('#test-console').append("F");
},
done: function(passed, failed, elapsed) {
$('#test-console').append("\n");
$('#test-console').append(passed + " passed " + failed + " failed " + "(" + elapsed + "ms)");
this.errors.forEach(function(err) {
$('#test-console').append("\n");
$('#test-console').append(dust.escapeHtml(dumpError(err)));
});
}
});
coreSetup(suite, dustExamples.slice(1), dust);
suite.run();
}
function dumpError(err) {
var out = err.testName + " -> ";
if (!err.message) {
err.message = jsDump.parse(err.expected)
+ " " + err.operator + " " + jsDump.parse(err.actual);
}
return out + err.stack;
}
$(document).ready(function() {
dustExamples.forEach(function(ex) {
dust.loadSource(dust.compile(ex.source, ex.name));
});
runSuite();
$('#tagline').empty().show().css({left: ($(window).width() * .02) + 125});
dust.loadSource(dust.compile(dustExamples[0].source, "intro"));
dust.stream("intro", dustExamples[0].context())
.on('data', function(data) {
$('#tagline').append(data);
})
.on('end', function() {
$('#tagline').delay(500).fadeOut('slow');
});
dust.render("select", {
examples: dustExamples,
selected: function(chk, ctx) {
if (ctx.current().name === "replace") return "selected";
}
}, function(err, output) {
$('#select').html(output);
});
$('#select > select').change(function() {
var idx = $(this).val();
$('#input-source').val(dustExamples[idx].source);
$('#input-context').val(dump(dustExamples[idx].context));
$('#input-source').change();
});
$('#input-source').change(function() {
setPending('#input-source');
try {
var compiled = dust.compile($(this).val(), "demo");
dust.loadSource(compiled);
$('#output-js').text(js_beautify(compiled, {
indent_size: 2
}));
setOkay('#input-source');
} catch(err) {
setError('#input-source', err);
return;
}
renderDemo();
});
$('#input-context').change(renderDemo);
var sections = $("body > div");
var cur_id;
$(window).scroll(function() {
var scrollTop = $(window).scrollTop();
if (scrollTop === 0) {
cur_id = undefined;
$('.docked').remove();
return;
}
sections.each(function(idx, section) {
var sectionTop = section.offsetTop,
sectionBottom = sectionTop + section.offsetHeight;
if (scrollTop >= sectionTop && scrollTop < sectionBottom) {
var $hdr = $(section).find('.header').clone();
if (section.id !== cur_id) {
cur_id = section.id;
$('.docked').remove();
$hdr.appendTo('body');
$hdr.addClass('docked');
}
return false;
}
});
});
$('#select > select').change();
$(window).scroll();
});

View File

@ -1,5 +0,0 @@
<select style="clear: both;">
{#examples}
<option {selected} value="{@idx}{.}{/idx}">{name}</option>
{/examples}
</select>

286
node_modules/dust/docs/syntax.md generated vendored
View File

@ -1,286 +0,0 @@
Dust is a JavaScript templating engine designed to provide a clean separation between presentation and logic without sacrificing ease of use. It is particularly well-suited for asynchronous and streaming applications.
### Syntax
Dust templates use two types of tags: _keys_ and _sections_. Keys reference fields within the current view context. You can think of them as placeholders that allow the context to insert data into the template. Sections accept template blocks that may be enumerated, filtered or transformed in various ways.
### Keys
To reference a key from the view context within the template, enclose the key in curly braces. For example, given the template below:
Hello {name}!
And the following view context:
{ name: "Fred" }
The resulting output would be:
Hello Fred!
If the _name_ key cannot be found in the view, Dust outputs an empty string:
Hello !
Generally, Dust casts whatever values it finds to strings. If Dust encounters a handler function it calls the function, passing in the current state of the template.
#### Filters
By default, the content of all key tags is HTML escaped, so assuming the _name_ key above resolves to a dangerous script tag:
<script>alert('I am evil!')</script>
This would be rendered as:
&lt;script&gt;alert('I am evil!')&lt;/script&gt;
To disable auto-escaping, append a pipe character '|' and an 's' to the end of the tag identifier, like so:
Hello {name|s}
There are several other built-in filters: `h` forces HTML escaping, `j` escapes JavaScript strings, `u` proxies to JavaScript's built-in `encodeURI`, and `uc` proxies to JavaScript's `encodeURIComponent`. Filters can also be chained together like so:
Hello {name|s|h|u}
When chained in this manner, filters are applied from left to right. Filters do not accept arguments; if you need more sophisticated behavior use a section tag instead.
### Sections
Keys are fine for simple lookups, but suppose the view context contains a _friends_ field which resolves to an array of objects containing _name_ and _age_ fields. This is where section tags are useful.
{#friends}
{name}, {age}{~n}
{/friends}
Here, the section begins with `{#friends}` and ends with `{/friends}`. Dust's default behavior is to enumerate over the array, passing each object in the array to the block. With a the following view context:
{
friends: [
{ name: "Moe", age: 37 },
{ name: "Larry", age: 39 },
{ name: "Curly", age: 35 }
]
}
The output is as one might expect:
Moe, 37
Larry, 39
Curly, 35
When _friends_ resolves to a value or object instead of an array, Dust sets the current context to the value and renders the block one time. If _friends_ resolves to a custom handler function, the function is given control over the section's behavior.
Dust outputs nothing if the friends key is empty or nonexistent. Let's change that by inserting an `{:else}` tag, which tells Dust to render an alternate template block when a section key resolves to a falsy value:
{#friends}
{name}, {age}{~n}
{:else}
You have no friends!
{/friends}
Now when the friends key is empty or nonexistent we get the following:
You have no friends!
Internally, Dust builds a stack of contexts as templates delve deeper into nested sections. If a key is not found within the current context, Dust looks for the key within the parent context, and its parent, and so on.
Self-closing section tags are allowed, so the template code below is permissible (although in this case it won't render anything):
{#friends/}
#### Paths
Paths allow you to reference keys relative to the current context.
{#names}{.} {/names}
The dot notation above lets the template reference the current context implicitly, so given an array of strings:
{ names: ["Moe", "Larry", "Curly"] }
The template block outputs each string in the array.
Moe Larry Curly
Paths can also be used to reach into nested contexts:
{foo.bar}
Or to constrain lookups to the current section scope:
{.foo}
To avoid brittle and confusing references, paths never backtrack up the context stack. If you need to drill into a key available within the parent context, pass the key as a parameter.
#### Inline Parameters
Inline parameters appear within the section's opening tag. Parameters are separated by a single space. By default, inline parameters merge values into the section's view context:
{#profile bar="baz" bing="bong"}
{name}, {bar}, {bing}
{/profile}
Assuming _name_ within the profile section resolves to "Fred", the output would be:
Fred, baz, bong
Inline parameters may be used to alias keys that conflict between parent and child contexts:
{name}{~n}
{#profile root_name=name}
{name}, {root_name}
{/profile}
Note here that we're passing in a key rather than a string literal. If the context is as follows:
{
name: "Foo",
profile: {
name: "Bar"
}
}
The output will be:
Foo
Bar, Foo
Parameters accept interpolated string literals as values:
{#snippet id="{name}_id"/}
#### Body Parameters
Unlike inline parameters, which modify the context, body parameters pass named template blocks to handler functions. Body parameters are useful for implementing striping or other complex behaviors that might otherwise involve manually assembling strings within your view functions. The only body parameter with default behavior is the `{:else}` tag as seen above.
#### Contexts
Normally, upon encountering a section tag Dust merges the section's context with the parent context. Sometimes it can be useful to manually set the context provided to a section. Sections accept a context argument for this purpose:
{#list:projects}{name}{/list}
Here, we're providing an array of _projects_ to the _list_ section, which might be a special helper defined on the view. If _list_ is not a function but some other value instead, its parent context is simply set to _projects_.
#### Special Sections
In addition to the standard hashed (`#`) section tag, Dust provides a few section tags with special semantics, namely the _exists_ tag (`?`), the _notexists_ tag (`^`), and the context helpers tag (`@`). These tags make it easier to work with plain JSON data without additional helpers.
The exists and notexists sections check for the existence (in the falsy sense) of a key within the current context. They do not alter the current context, making it possible to, for instance, check that an array is non-empty before wrapping it in HTML list tags:
{?tags}
<ul>
{#tags}
<li>{.}</li>
{/tags}
</ul>
{:else}
No Tags!
{/tags}
Unlike regular sections, conditional sections do not evaluate functions defined on the view. In those cases you'll still have to write your own handlers.
The context helpers tag provides a couple of convenience functions to support iteration. The `sep` tag prints the enclosed block for every value except for the last. The `idx` tag passes the numerical index of the current element to the enclosed block.
{#names}{.}{@idx}{.}{/idx}{@sep}, {/sep}{/names}
The template above might output something like:
Moe0, Larry1, Curly2
### Partials
Partials, also known as template includes, allow you to compose templates at runtime.
{>profile/}
The block above looks for a template named "profile" and inserts its output into the parent template. Like sections, partials inherit the current context. And like sections, partials accept a context argument:
{>profile:user/}
Partial tags also accept string literals and interpolated string literals as keys:
{>"path/to/comments.dust.html"/}
{>"posts/{type}.dust.html"/}
This is useful when you're retrieving templates from the filesystem and the template names wouldn't otherwise be valid identifiers, or when selecting templates dynamically based on information from the view context.
### Blocks and Inline Partials
Often you'll want to have a template inherit the bulk of its content from a common base template. Dust solves this problem via blocks and inline partials. When placed within a template, blocks allow you to define snippets of template code that may be overriden by any templates that reference this template:
Start{~n}
{+title}
Base Title
{/title}
{~n}
{+main}
Base Content
{/main}
{~n}
End
Notice the special syntax for blocks: `{+block} ... {/block}`. When this template is rendered standalone, Dust simply renders the content within the blocks:
Start
Base Title
Base Content
End
But when the template is invoked from another template that contains inline partial tags (`{<snippet} ... {/snippet}`):
{>base_template/}
{<title}
Child Title
{/title}
{<main}
Child Content
{/main}
Dust overrides the block contents of the base template:
Start
Child Title
Child Content
End
A block may be self-closing (`{+block/}`), in which case it is not displayed unless a calling template overrides the content of the block. Inline partials never output content themselves, and are always global to the template in which they are defined, so the order of their definition has no significance. They are passed to all templates invoked by the template in which they are defined.
Note that blocks can be used to render inline partials that are defined within the same template. This is useful when you want to use the same template to serve AJAX requests and regular requests:
{^xhr}
{>base_template/}
{:else}
{+main/}
{/xhr}
{<title}
Child Title
{/title}
{<main}
Child Content
{/main}
### Static Text
The Dust parser is finely tuned to minimize the amount of escaping that needs to be done within static text. Any text that does not closely resemble a Dust tag is considered static and will be passed through untouched to the template's output. This makes Dust suitable for use in templating many different formats. In order to be recognized as such, Dust tags should not contain extraneous whitespace and newlines.
#### Special Characters
Depending on whitespace and delimeter settings, it is sometimes necessary to include escape tags within static text. Escape tags begin with a tilde (`~`), followed by a key identifying the desired escape sequence. Currently newline (`n`), carriage return (`r`), space (`s`), left brace (`lb`) and right brace (`rb`) are supported. For example:
Hello World!{~n}
Inserts a newline after the text. By default, Dust compresses whitespace by eliminating newlines and indentation. This behavior can be toggled at compile time.
#### Comments
Comments, which do not appear in template output, begin and end with a bang (`!`):
{!
Multiline
{#foo}{bar}{/foo}
!}
{!before!}Hello{!after!}
The template above would render as follows:
Hello

1078
node_modules/dust/index.html generated vendored

File diff suppressed because it is too large Load Diff

319
node_modules/dust/lib/compiler.js generated vendored
View File

@ -1,319 +0,0 @@
(function(dust) {
dust.compile = function(source, name) {
var ast = filterAST(dust.parse(source));
return compile(ast, name);
};
function filterAST(ast) {
var context = {};
return dust.filterNode(context, ast);
}
dust.filterNode = function(context, node) {
return dust.optimizers[node[0]](context, node);
}
dust.optimizers = {
body: compactBuffers,
buffer: noop,
special: convertSpecial,
format: nullify, // TODO: convert format
reference: visit,
"#": visit,
"?": visit,
"^": visit,
"<": visit,
"+": visit,
"@": visit,
"%": visit,
partial: visit,
context: visit,
params: visit,
bodies: visit,
param: visit,
filters: noop,
key: noop,
path: noop,
literal: noop,
comment: nullify
}
dust.pragmas = {
esc: function(compiler, context, bodies, params) {
var old = compiler.auto;
if (!context) context = 'h';
compiler.auto = (context === 's') ? '' : context;
var out = compileParts(compiler, bodies.block);
compiler.auto = old;
return out;
}
}
function visit(context, node) {
var out = [node[0]];
for (var i=1, len=node.length; i<len; i++) {
var res = dust.filterNode(context, node[i]);
if (res) out.push(res);
}
return out;
}
// Compacts consecutive buffer nodes into a single node
function compactBuffers(context, node) {
var out = [node[0]], memo;
for (var i=1, len=node.length; i<len; i++) {
var res = dust.filterNode(context, node[i]);
if (res) {
if (res[0] === 'buffer') {
if (memo) {
memo[1] += res[1];
} else {
memo = res;
out.push(res);
}
} else {
memo = null;
out.push(res);
}
}
}
return out;
}
var specialChars = {
"s": " ",
"n": "\n",
"r": "\r",
"lb": "{",
"rb": "}"
};
function convertSpecial(context, node) { return ['buffer', specialChars[node[1]]] }
function noop(context, node) { return node }
function nullify(){}
function compile(ast, name) {
var context = {
name: name,
bodies: [],
blocks: {},
index: 0,
auto: "h"
}
return "(function(){dust.register("
+ (name ? "\"" + name + "\"" : "null") + ","
+ dust.compileNode(context, ast)
+ ");"
+ compileBlocks(context)
+ compileBodies(context)
+ "return body_0;"
+ "})();";
}
function compileBlocks(context) {
var out = [],
blocks = context.blocks;
for (var name in blocks) {
out.push(name + ":" + blocks[name]);
}
if (out.length) {
context.blocks = "ctx=ctx.shiftBlocks(blocks);";
return "var blocks={" + out.join(',') + "};";
}
return context.blocks = "";
}
function compileBodies(context) {
var out = [],
bodies = context.bodies,
blx = context.blocks;
for (var i=0, len=bodies.length; i<len; i++) {
out[i] = "function body_" + i + "(chk,ctx){"
+ blx + "return chk" + bodies[i] + ";}";
}
return out.join('');
}
function compileParts(context, body) {
var parts = '';
for (var i=1, len=body.length; i<len; i++) {
parts += dust.compileNode(context, body[i]);
}
return parts;
}
dust.compileNode = function(context, node) {
return dust.nodes[node[0]](context, node);
}
dust.nodes = {
body: function(context, node) {
var id = context.index++, name = "body_" + id;
context.bodies[id] = compileParts(context, node);
return name;
},
buffer: function(context, node) {
return ".write(" + escape(node[1]) + ")";
},
format: function(context, node) {
return ".write(" + escape(node[1] + node[2]) + ")";
},
reference: function(context, node) {
return ".reference(" + dust.compileNode(context, node[1])
+ ",ctx," + dust.compileNode(context, node[2]) + ")";
},
"#": function(context, node) {
return compileSection(context, node, "section");
},
"?": function(context, node) {
return compileSection(context, node, "exists");
},
"^": function(context, node) {
return compileSection(context, node, "notexists");
},
"<": function(context, node) {
var bodies = node[4];
for (var i=1, len=bodies.length; i<len; i++) {
var param = bodies[i],
type = param[1][1];
if (type === "block") {
context.blocks[node[1].text] = dust.compileNode(context, param[2]);
return '';
}
}
return '';
},
"+": function(context, node) {
return ".block(ctx.getBlock("
+ escape(node[1].text)
+ ")," + dust.compileNode(context, node[2]) + ","
+ dust.compileNode(context, node[4]) + ","
+ dust.compileNode(context, node[3])
+ ")";
},
"@": function(context, node) {
return ".helper("
+ escape(node[1].text)
+ "," + dust.compileNode(context, node[2]) + ","
+ dust.compileNode(context, node[4]) + ","
+ dust.compileNode(context, node[3])
+ ")";
},
"%": function(context, node) {
// TODO: Move these hacks into pragma precompiler
var name = node[1][1];
if (!dust.pragmas[name]) return '';
var rawBodies = node[4];
var bodies = {};
for (var i=1, len=rawBodies.length; i<len; i++) {
var b = rawBodies[i];
bodies[b[1][1]] = b[2];
}
var rawParams = node[3];
var params = {};
for (var i=1, len=rawParams.length; i<len; i++) {
var p = rawParams[i];
params[p[1][1]] = p[2][1];
}
var ctx = node[2][1] ? node[2][1].text : null;
return dust.pragmas[name](context, ctx, bodies, params);
},
partial: function(context, node) {
return ".partial("
+ dust.compileNode(context, node[1])
+ "," + dust.compileNode(context, node[2]) + ")";
},
context: function(context, node) {
if (node[1]) {
return "ctx.rebase(" + dust.compileNode(context, node[1]) + ")";
}
return "ctx";
},
params: function(context, node) {
var out = [];
for (var i=1, len=node.length; i<len; i++) {
out.push(dust.compileNode(context, node[i]));
}
if (out.length) {
return "{" + out.join(',') + "}";
}
return "null";
},
bodies: function(context, node) {
var out = [];
for (var i=1, len=node.length; i<len; i++) {
out.push(dust.compileNode(context, node[i]));
}
return "{" + out.join(',') + "}";
},
param: function(context, node) {
return dust.compileNode(context, node[1]) + ":" + dust.compileNode(context, node[2]);
},
filters: function(context, node) {
var list = [];
for (var i=1, len=node.length; i<len; i++) {
var filter = node[i];
list.push("\"" + filter + "\"");
}
return "\"" + context.auto + "\""
+ (list.length ? ",[" + list.join(',') + "]" : '');
},
key: function(context, node) {
return "ctx.get(\"" + node[1] + "\")";
},
path: function(context, node) {
var current = node[1],
keys = node[2],
list = [];
for (var i=0,len=keys.length; i<len; i++) {
list.push("\"" + keys[i] + "\"");
}
return "ctx.getPath(" + current + ",[" + list.join(',') + "])";
},
literal: function(context, node) {
return escape(node[1]);
}
}
function compileSection(context, node, cmd) {
return "." + cmd + "("
+ dust.compileNode(context, node[1])
+ "," + dust.compileNode(context, node[2]) + ","
+ dust.compileNode(context, node[4]) + ","
+ dust.compileNode(context, node[3])
+ ")";
}
var escape = (typeof JSON === "undefined")
? function(str) { return "\"" + dust.escapeJs(str) + "\"" }
: JSON.stringify;
})(typeof exports !== 'undefined' ? exports : window.dust);

514
node_modules/dust/lib/dust.js generated vendored
View File

@ -1,514 +0,0 @@
var dust = {};
(function(dust) {
dust.cache = {};
dust.register = function(name, tmpl) {
if (!name) return;
dust.cache[name] = tmpl;
};
dust.render = function(name, context, callback) {
var chunk = new Stub(callback).head;
dust.load(name, chunk, Context.wrap(context)).end();
};
dust.stream = function(name, context) {
var stream = new Stream();
dust.nextTick(function() {
dust.load(name, stream.head, Context.wrap(context)).end();
});
return stream;
};
dust.renderSource = function(source, context, callback) {
return dust.compileFn(source)(context, callback);
};
dust.compileFn = function(source, name) {
var tmpl = dust.loadSource(dust.compile(source, name));
return function(context, callback) {
var master = callback ? new Stub(callback) : new Stream();
dust.nextTick(function() {
tmpl(master.head, Context.wrap(context)).end();
});
return master;
}
};
dust.load = function(name, chunk, context) {
var tmpl = dust.cache[name];
if (tmpl) {
return tmpl(chunk, context);
} else {
if (dust.onLoad) {
return chunk.map(function(chunk) {
dust.onLoad(name, function(err, src) {
if (err) return chunk.setError(err);
if (!dust.cache[name]) dust.loadSource(dust.compile(src, name));
dust.cache[name](chunk, context).end();
});
});
}
return chunk.setError(new Error("Template Not Found: " + name));
}
};
dust.loadSource = function(source, path) {
return eval(source);
};
if (Array.isArray) {
dust.isArray = Array.isArray;
} else {
dust.isArray = function(arr) {
return Object.prototype.toString.call(arr) == "[object Array]";
};
}
dust.nextTick = function(callback) {
setTimeout(callback, 0);
}
dust.isEmpty = function(value) {
if (dust.isArray(value) && !value.length) return true;
if (value === 0) return false;
return (!value);
};
dust.filter = function(string, auto, filters) {
if (filters) {
for (var i=0, len=filters.length; i<len; i++) {
var name = filters[i];
if (name === "s") {
auto = null;
} else {
string = dust.filters[name](string);
}
}
}
if (auto) {
string = dust.filters[auto](string);
}
return string;
};
dust.filters = {
h: function(value) { return dust.escapeHtml(value); },
j: function(value) { return dust.escapeJs(value); },
u: encodeURI,
uc: encodeURIComponent
}
function Context(stack, global, blocks) {
this.stack = stack;
this.global = global;
this.blocks = blocks;
}
dust.makeBase = function(global) {
return new Context(new Stack(), global);
}
Context.wrap = function(context) {
if (context instanceof Context) {
return context;
}
return new Context(new Stack(context));
}
Context.prototype.get = function(key) {
var ctx = this.stack, value;
while(ctx) {
if (ctx.isObject) {
value = ctx.head[key];
if (!(value === undefined)) {
return value;
}
}
ctx = ctx.tail;
}
return this.global ? this.global[key] : undefined;
};
Context.prototype.getPath = function(cur, down) {
var ctx = this.stack,
len = down.length;
if (cur && len === 0) return ctx.head;
if (!ctx.isObject) return undefined;
ctx = ctx.head;
var i = 0;
while(ctx && i < len) {
ctx = ctx[down[i]];
i++;
}
return ctx;
};
Context.prototype.push = function(head, idx, len) {
return new Context(new Stack(head, this.stack, idx, len), this.global, this.blocks);
};
Context.prototype.rebase = function(head) {
return new Context(new Stack(head), this.global, this.blocks);
};
Context.prototype.current = function() {
return this.stack.head;
};
Context.prototype.getBlock = function(key) {
var blocks = this.blocks;
if (!blocks) return;
var len = blocks.length, fn;
while (len--) {
fn = blocks[len][key];
if (fn) return fn;
}
}
Context.prototype.shiftBlocks = function(locals) {
var blocks = this.blocks;
if (locals) {
if (!blocks) {
newBlocks = [locals];
} else {
newBlocks = blocks.concat([locals]);
}
return new Context(this.stack, this.global, newBlocks);
}
return this;
}
function Stack(head, tail, idx, len) {
this.tail = tail;
this.isObject = !dust.isArray(head) && head && typeof head === "object";
this.head = head;
this.index = idx;
this.of = len;
}
function Stub(callback) {
this.head = new Chunk(this);
this.callback = callback;
this.out = '';
}
Stub.prototype.flush = function() {
var chunk = this.head;
while (chunk) {
if (chunk.flushable) {
this.out += chunk.data;
} else if (chunk.error) {
this.callback(chunk.error);
this.flush = function() {};
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.callback(null, this.out);
}
function Stream() {
this.head = new Chunk(this);
}
Stream.prototype.flush = function() {
var chunk = this.head;
while(chunk) {
if (chunk.flushable) {
this.emit('data', chunk.data);
} else if (chunk.error) {
this.emit('error', chunk.error);
this.flush = function() {};
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.emit('end');
}
Stream.prototype.emit = function(type, data) {
var events = this.events;
if (events && events[type]) {
events[type](data);
}
}
Stream.prototype.on = function(type, callback) {
if (!this.events) {
this.events = {};
}
this.events[type] = callback;
return this;
}
function Chunk(root, next, taps) {
this.root = root;
this.next = next;
this.data = '';
this.flushable = false;
this.taps = taps;
}
Chunk.prototype.write = function(data) {
var taps = this.taps;
if (taps) {
data = taps.go(data);
}
this.data += data;
return this;
}
Chunk.prototype.end = function(data) {
if (data) {
this.write(data);
}
this.flushable = true;
this.root.flush();
return this;
}
Chunk.prototype.map = function(callback) {
var cursor = new Chunk(this.root, this.next, this.taps),
branch = new Chunk(this.root, cursor, this.taps);
this.next = branch;
this.flushable = true;
callback(branch);
return cursor;
}
Chunk.prototype.tap = function(tap) {
var taps = this.taps;
if (taps) {
this.taps = taps.push(tap);
} else {
this.taps = new Tap(tap);
}
return this;
}
Chunk.prototype.untap = function() {
this.taps = this.taps.tail;
return this;
}
Chunk.prototype.render = function(body, context) {
return body(this, context);
}
Chunk.prototype.reference = function(elem, context, auto, filters) {
if (typeof elem === "function") {
elem = elem(this, context, null, {auto: auto, filters: filters});
if (elem instanceof Chunk) {
return elem;
}
}
if (!dust.isEmpty(elem)) {
return this.write(dust.filter(elem, auto, filters));
} else {
return this;
}
};
Chunk.prototype.section = function(elem, context, bodies, params) {
if (typeof elem === "function") {
elem = elem(this, context, bodies, params);
if (elem instanceof Chunk) {
return elem;
}
}
var body = bodies.block,
skip = bodies['else'];
if (params) {
context = context.push(params);
}
if (dust.isArray(elem)) {
if (body) {
var len = elem.length, chunk = this;
for (var i=0; i<len; i++) {
chunk = body(chunk, context.push(elem[i], i, len));
}
return chunk;
}
} else if (elem === true) {
if (body) return body(this, context);
} else if (elem || elem === 0) {
if (body) return body(this, context.push(elem));
} else if (skip) {
return skip(this, context);
}
return this;
};
Chunk.prototype.exists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (!dust.isEmpty(elem)) {
if (body) return body(this, context);
} else if (skip) {
return skip(this, context);
}
return this;
}
Chunk.prototype.notexists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (dust.isEmpty(elem)) {
if (body) return body(this, context);
} else if (skip) {
return skip(this, context);
}
return this;
}
Chunk.prototype.block = function(elem, context, bodies) {
var body = bodies.block;
if (elem) {
body = elem;
}
if (body) {
return body(this, context);
}
return this;
};
Chunk.prototype.partial = function(elem, context) {
if (typeof elem === "function") {
return this.capture(elem, context, function(name, chunk) {
dust.load(name, chunk, context).end();
});
}
return dust.load(elem, this, context);
};
Chunk.prototype.helper = function(name, context, bodies, params) {
return dust.helpers[name](this, context, bodies, params);
};
Chunk.prototype.capture = function(body, context, callback) {
return this.map(function(chunk) {
var stub = new Stub(function(err, out) {
if (err) {
chunk.setError(err);
} else {
callback(out, chunk);
}
});
body(stub.head, context).end();
});
};
Chunk.prototype.setError = function(err) {
this.error = err;
this.root.flush();
return this;
};
dust.helpers = {
sep: function(chunk, context, bodies) {
if (context.stack.index === context.stack.of - 1) {
return chunk;
}
return bodies.block(chunk, context);
},
idx: function(chunk, context, bodies) {
return bodies.block(chunk, context.push(context.stack.index));
}
}
function Tap(head, tail) {
this.head = head;
this.tail = tail;
}
Tap.prototype.push = function(tap) {
return new Tap(tap, this);
};
Tap.prototype.go = function(value) {
var tap = this;
while(tap) {
value = tap.head(value);
tap = tap.tail;
}
return value;
};
var HCHARS = new RegExp(/[&<>\"]/),
AMP = /&/g,
LT = /</g,
GT = />/g,
QUOT = /\"/g;
dust.escapeHtml = function(s) {
if (typeof s === "string") {
if (!HCHARS.test(s)) {
return s;
}
return s.replace(AMP,'&amp;').replace(LT,'&lt;').replace(GT,'&gt;').replace(QUOT,'&quot;');
}
return s;
};
var BS = /\\/g,
CR = /\r/g,
LS = /\u2028/g,
PS = /\u2029/g,
NL = /\n/g,
LF = /\f/g,
SQ = /'/g,
DQ = /"/g,
TB = /\t/g;
dust.escapeJs = function(s) {
if (typeof s === "string") {
return s
.replace(BS, '\\\\')
.replace(DQ, '\\"')
.replace(SQ, "\\'")
.replace(CR, '\\r')
.replace(LS, '\\u2028')
.replace(PS, '\\u2029')
.replace(NL, '\\n')
.replace(LF, '\\f')
.replace(TB, "\\t");
}
return s;
};
})(dust);
if (typeof exports !== "undefined") {
if (typeof process !== "undefined") {
require('./server')(dust);
}
module.exports = dust;
}

2368
node_modules/dust/lib/parser.js generated vendored

File diff suppressed because it is too large Load Diff

20
node_modules/dust/lib/server.js generated vendored
View File

@ -1,20 +0,0 @@
var path = require('path'),
parser = require('./parser'),
compiler = require('./compiler'),
Script = process.binding('evals').Script;
require.paths.unshift(path.join(__dirname, '..'));
module.exports = function(dust) {
compiler.parse = parser.parse;
dust.compile = compiler.compile;
dust.loadSource = function(source, path) {
return Script.runInNewContext(source, {dust: dust}, path);
};
dust.nextTick = process.nextTick;
// expose optimizers in commonjs env too
dust.optimizers = compiler.optimizers;
}

View File

@ -1 +0,0 @@
platform.active=Ruby

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>

View File

@ -1,19 +0,0 @@
clean=Remove any temporary products.
clobber=Remove any generated file.
clobber_package=Remove package products
clobber_rdoc=Remove rdoc products
doc=
doc/rdoc=
doc/rdoc/index.html=
gem=Build the gem file dust-0.0.1.gem
package=Build all the packages
pkg=
pkg/dust-0.0.1=
pkg/dust-0.0.1.gem=
pkg/dust-0.0.1.tgz=
pkg/dust-0.0.1.zip=
rdoc=Build the rdoc HTML Files
repackage=Force a rebuild of the package files
rerdoc=Force a rebuild of the RDOC files
spec=Run specs
test=Run tests

View File

@ -1,6 +0,0 @@
javac.classpath=
main.file=
platform.active=Ruby
source.encoding=UTF-8
src.lib.dir=lib
src.src.dir=src

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ruby.rubyproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
<name>dust</name>
<source-roots>
<root id="src.lib.dir"/>
<root id="src.src.dir"/>
</source-roots>
<test-roots/>
</data>
</configuration>
</project>

45
node_modules/dust/package.json generated vendored
View File

@ -1,45 +0,0 @@
{
"name": "dust",
"version": "0.3.0",
"description": "Asynchronous templates for the browser and node.js",
"author": {
"name": "Aleksander Williams"
},
"contributors": [],
"url": "http://akdubya.github.com/dustjs/",
"keywords": [
"templates",
"views"
],
"main": "./lib/dust",
"scripts": {
"test": "make test"
},
"_id": "dust@0.3.0",
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "0.2.14",
"_nodeVersion": "v0.3.2-pre",
"directories": {
"lib": "./lib"
},
"modules": {
"compiler.js": "lib/compiler.js",
"dust.js": "lib/dust.js",
"parser.js": "lib/parser.js",
"server.js": "lib/server.js"
},
"files": [
""
],
"_defaultsLoaded": true,
"dist": {
"shasum": "86b65a9a9769a50de9f2c7ad998503019a1564a5",
"tarball": "http://registry.npmjs.org/dust/-/dust-0.3.0.tgz"
},
"_shasum": "86b65a9a9769a50de9f2c7ad998503019a1564a5",
"_from": "dust@0.3.0",
"_resolved": "https://registry.npmjs.org/dust/-/dust-0.3.0.tgz"
}

12
node_modules/dust/src/build.js generated vendored
View File

@ -1,12 +0,0 @@
var peg = require('peg'),
fs = require('fs'),
path = require('path'),
root = path.join(path.dirname(__filename), "..");
var parser = peg.buildParser(fs.readFileSync(path.join(root, 'src', 'dust.pegjs'), 'utf8'));
fs.writeFileSync(path.join(root, 'lib', 'parser.js'), "(function(dust){\n\nvar parser = "
+ parser.toSource().replace('this.SyntaxError', 'SyntaxError') + ";\n\n"
+ "dust.parse = parser.parse;\n\n"
+ "})(typeof exports !== 'undefined' ? exports : window.dust);"
);

118
node_modules/dust/src/dust.pegjs generated vendored
View File

@ -1,118 +0,0 @@
{
function wrap(node, ck) {
node['text'] = input.substring(ck.split('@')[1], pos);
return node;
}
}
start
= body
body
= p:part* { return ["body"].concat(p) }
part
= comment / section / partial / special / reference / buffer
section "section"
= t:sec_tag_start rd b:body e:bodies n:end_tag
&{return result8[1].text === result12.text}
{ e.push(["param", ["literal", "block"], b]); t.push(e); return t }
/ t:sec_tag_start "/" rd
{ t.push(["bodies"]); return t }
sec_tag_start
= ld t:[#?^<+@%] n:identifier c:context p:params
{ return [t, n, c, p] }
end_tag "end tag"
= ld "/" n:identifier rd
{ return n }
context
= n:(":" n:identifier {return n})?
{ return n ? ["context", n] : ["context"] }
params "params"
= p:(ws k:key "=" v:(identifier / inline) {return ["param", ["literal", k], v]})*
{ return ["params"].concat(p) }
bodies "bodies"
= p:(ld ":" k:key rd v:body {return ["param", ["literal", k], v]})*
{ return ["bodies"].concat(p) }
reference "reference"
= ld n:identifier f:filters rd
{ return ["reference", n, f] }
partial "partial"
= ld ">" n:(k:key {return ["literal", k]} / inline) c:context "/" rd
{ return ["partial", n, c] }
filters "filters"
= f:("|" n:key {return n})*
{ return ["filters"].concat(f) }
special "special"
= ld "~" k:key rd
{ return ["special", k] }
identifier "identifier"
= p:path { return wrap(["path"].concat(p), cacheKey) }
/ k:key { return wrap(["key", k], cacheKey) }
path "path"
= k:key? d:("." k:key {return k})+ {
if (k) { d.unshift(k); return [false, d]; }
return [true, d];
}
/ "." { return [true, []] }
key "key"
= h:[a-zA-Z_$] t:[0-9a-zA-Z_$]*
{ return h + t.join('') }
inline "inline"
= '"' '"' { return ["literal", ""] }
/ '"' l:literal '"' { return ["literal", l] }
/ '"' p:inline_part+ '"' { return ["body"].concat(p) }
inline_part
= special / reference / l:literal { return ["buffer", l] }
buffer "buffer"
= e:eol w:ws*
{ return ["format", e, w.join('')] }
/ b:(!tag !eol !comment c:. {return c})+
{ return ["buffer", b.join('')] }
literal "literal"
= b:(!tag !eol c:(esc / [^"]) {return c})+
{ return b.join('') }
esc
= '\\"' { return '"' }
comment "comment"
= "{!" c:(!"!}" c:. {return c})* "!}"
{ return ["comment", c.join('')] }
tag
= ld [#?^><+%:@/~%] (!rd !eol .)+ rd
/ reference
ld
= "{"
rd
= "}"
eol
= "\n"
/ "\r\n"
/ "\r"
/ "\u2028"
/ "\u2029"
ws
= [\t\v\f \u00A0\uFEFF]

83
node_modules/dust/test/core.js generated vendored
View File

@ -1,83 +0,0 @@
(function(exports){
exports.coreSetup = function(suite, auto) {
auto.forEach(function(test) {
suite.test(test.name, function(){
testRender(this, test.source, test.context, test.expected);
});
});
suite.test("base context", function() {
var base = dust.makeBase({
sayHello: function() { return "Hello!" }
});
testRender(this, "{sayHello} {foo}", base.push({foo: "bar"}), "Hello! bar");
});
suite.test("valid keys", function() {
testRender(this, "{_foo}{$bar}{baz1}", {_foo: 1, $bar: 2, baz1: 3}, "123");
});
suite.test("onLoad callback", function() {
var unit = this;
dust.onLoad = function(name, cb) {
cb(null, "Loaded: " + name);
};
dust.render("onLoad", {}, function(err, out) {
try {
unit.ifError(err);
unit.equals(out, "Loaded: onLoad");
} catch(err) {
unit.fail(err);
return;
}
unit.pass();
});
});
suite.test("renderSource (callback)", function() {
var unit = this;
dust.renderSource('Hello World', {}, function(err, out) {
try {
unit.ifError(err);
unit.equals(out, "Hello World");
} catch(err) {
unit.fail(err);
return;
}
unit.pass();
});
});
suite.test("renderSource (stream)", function() {
var unit = this;
dust.renderSource('Hello World', {}).on('data', function(data) {
try {
unit.equals('Hello World', data);
} catch(err) {
unit.fail(err);
return;
}
unit.pass();
}).on('error', function(err) {
unit.fail(err);
});
});
}
function testRender(unit, source, context, expected) {
var name = unit.id;
dust.loadSource(dust.compile(source, name));
dust.render(name, context, function(err, output) {
try {
unit.ifError(err);
unit.equals(output, expected);
} catch(err) {
unit.fail(err);
return;
}
unit.pass();
});
}
})(typeof exports !== "undefined" ? exports : window);

318
node_modules/dust/test/examples.js generated vendored
View File

@ -1,318 +0,0 @@
(function(exports){
exports.dustExamples = [
{
name: "intro",
source: "{#stream}{#delay}{.}{/delay}{/stream}",
context: (function(){
var d = 1;
return {
stream: function() {
return "asynchronous templates for the browser and node.js".split('');
},
delay: function(chunk, context, bodies) {
return chunk.map(function(chunk) {
setTimeout(function() {
chunk.render(bodies.block, context).end();
}, d++ * 15);
});
}
}
})
},
{
name: "plain",
source: "Hello World!",
context: {},
expected: "Hello World!"
},
{
name: "replace",
source: "Hello {name}! You have {count} new messages.",
context: { name: "Mick", count: 30 },
expected: "Hello Mick! You have 30 new messages."
},
{
name: "zero",
source: "{#zero}{.}{/zero}",
context: { zero: 0 },
expected: "0"
},
{
name: "array",
source: "{#names}{title} {name}{~n}{/names}",
context: { title: "Sir", names: [ { name: "Moe" }, { name: "Larry" }, { name: "Curly" } ] },
expected: "Sir Moe\nSir Larry\nSir Curly\n"
},
{
name: "empty_array",
source: "{#names}{title} {name}{~n}{/names}",
context: { title: "Sir", names: [] },
expected: ""
},
{
name: "implicit",
source: "{#names}{.}{~n}{/names}",
context: { names: ["Moe", "Larry", "Curly"] },
expected: "Moe\nLarry\nCurly\n"
},
{
name: "object",
source: "{#person}{root}: {name}, {age}{/person}",
context: { root: "Subject", person: { name: "Larry", age: 45 } },
expected: "Subject: Larry, 45"
},
{
name: "rename_key",
source: "{#person foo=root}{foo}: {name}, {age}{/person}",
context: { root: "Subject", person: { name: "Larry", age: 45 } },
expected: "Subject: Larry, 45"
},
{
name: "force_current",
source: "{#person}{.root}: {name}, {age}{/person}",
context: { root: "Subject", person: { name: "Larry", age: 45 } },
expected: ": Larry, 45"
},
{
name: "path",
source: "{foo.bar}",
context: { foo: {bar: "Hello!"} },
expected: "Hello!"
},
{
name: "escaped",
source: "{safe|s}{~n}{unsafe}",
context: { safe: "<script>alert('Hello!')</script>", unsafe: "<script>alert('Goodbye!')</script>" },
expected: "<script>alert('Hello!')</script>\n&lt;script&gt;alert('Goodbye!')&lt;/script&gt;"
},
{
name: "escape_pragma",
source: "{%esc:s}\n {unsafe}{~n}\n {%esc:h}\n {unsafe}\n {/esc}\n{/esc}",
context: { unsafe: "<script>alert('Goodbye!')</script>" },
expected: "<script>alert('Goodbye!')</script>\n&lt;script&gt;alert('Goodbye!')&lt;/script&gt;"
},
{
name: "else_block",
source: "{#foo}\n" +
" foo,{~s}\n" +
"{:else}\n" +
" not foo,{~s}\n" +
"{/foo}\n" +
"{#bar}\n" +
" bar!\n" +
"{:else}\n" +
" not bar!\n" +
"{/bar}",
context: { foo: true, bar: false },
expected: "foo, not bar!"
},
{
name: "conditional",
source: "{?tags}\n" +
" <ul>{~n}\n" +
" {#tags}\n" +
" {~s} <li>{.}</li>{~n}\n" +
" {/tags}\n" +
" </ul>\n" +
"{:else}\n" +
" No Tags!\n" +
"{/tags}\n" +
"{~n}\n" +
"{^likes}\n" +
" No Likes!\n" +
"{:else}\n" +
" <ul>{~n}\n" +
" {#likes}\n" +
" {~s} <li>{.}</li>{~n}\n" +
" {/likes}\n" +
" </ul>\n" +
"{/likes}",
context: { tags: [], likes: ["moe", "larry", "curly", "shemp"] },
expected: "No Tags!\n" +
"<ul>\n" +
" <li>moe</li>\n" +
" <li>larry</li>\n" +
" <li>curly</li>\n" +
" <li>shemp</li>\n" +
"</ul>"
},
{
name: "sync_key",
source: "Hello {type} World!",
context: {
type: function(chunk) {
return "Sync";
}
},
expected: "Hello Sync World!"
},
{
name: "async_key",
source: "Hello {type} World!",
context: {
type: function(chunk) {
return chunk.map(function(chunk) {
dust.nextTick(function() {
chunk.end("Async");
});
});
}
},
expected: "Hello Async World!"
},
{
name: "sync_chunk",
source: "Hello {type} World!",
context: {
type: function(chunk) {
return chunk.write("Chunky");
}
},
expected: "Hello Chunky World!"
},
{
name: "async_iterator",
source: "{#numbers}{#delay}{.}{/delay}{@sep}, {/sep}{/numbers}",
context: {
numbers: [3, 2, 1],
delay: function(chunk, context, bodies) {
return chunk.map(function(chunk) {
setTimeout(function() {
chunk.render(bodies.block, context).end();
}, Math.ceil(Math.random()*10));
});
}
},
expected: "3, 2, 1"
},
{
name: "filter",
source: "{#filter}foo {bar}{/filter}",
context: {
filter: function(chunk, context, bodies) {
return chunk.tap(function(data) {
return data.toUpperCase();
}).render(bodies.block, context).untap();
},
bar: "bar"
},
expected: "FOO BAR"
},
{
name: "context",
source: "{#list:projects}{name}{:else}No Projects!{/list}",
context: {
list: function(chunk, context, bodies) {
var items = context.current(),
len = items.length;
if (len) {
chunk.write("<ul>\n");
for (var i=0; i<len; i++) {
chunk = chunk.write("<li>")
.render(bodies.block, context.push(items[i]))
.write("</li>\n");
}
return chunk.write("</ul>");
} else if (bodies['else']) {
return chunk.render(bodies['else'], context);
}
return chunk;
},
projects: [
{name: "Mayhem"},
{name: "Flash"},
{name: "Thunder"}
]
},
expected: "<ul>\n" +
"<li>Mayhem</li>\n" +
"<li>Flash</li>\n" +
"<li>Thunder</li>\n" +
"</ul>"
},
{
name: "params",
source: "{#helper foo=\"bar\"/}",
context: {
helper: function(chunk, context, bodies, params) {
return chunk.write(params.foo);
}
},
expected: "bar"
},
{
name: "partials",
source: '{>replace/} {>"plain"/} {>"{ref}"/}',
context: { name: "Jim", count: 42, ref: "plain" },
expected: "Hello Jim! You have 42 new messages. Hello World! Hello World!"
},
{
name: "partial_context",
source: "{>replace:.profile/}",
context: { profile: { name: "Mick", count: 30 } },
expected: "Hello Mick! You have 30 new messages."
},
{
name: "base_template",
source: "Start{~n}\n" +
"{+title}\n" +
" Base Title\n" +
"{/title}\n" +
"{~n}\n" +
"{+main}\n" +
" Base Content\n" +
"{/main}\n" +
"{~n}\n" +
"End",
context: {},
expected: "Start\nBase Title\nBase Content\nEnd"
},
{
name: "child_template",
source: "{^xhr}\n" +
" {>base_template/}\n" +
"{:else}\n" +
" {+main/}\n" +
"{/xhr}\n" +
"{<title}\n" +
" Child Title\n" +
"{/title}\n" +
"{<main}\n" +
" Child Content\n" +
"{/main}\n",
context: {xhr: false},
expected: "Start\nChild Title\nChild Content\nEnd"
},
{
name: "recursion",
source: "{name}{~n}{#kids}{>recursion:./}{/kids}",
context: {
name: '1',
kids: [
{
name: '1.1',
kids: [
{name: '1.1.1'}
]
}
]
},
expected: "1\n1.1\n1.1.1\n"
},
{
name: "comments",
source: "{!\n" +
" Multiline\n" +
" {#foo}{bar}{/foo}\n" +
"!}\n" +
"{!before!}Hello{!after!}",
context: {},
expected: "Hello"
}
];
})(typeof exports !== "undefined" ? exports : window);

35
node_modules/dust/test/server.js generated vendored
View File

@ -1,35 +0,0 @@
var uutest = require('./uutest'),
dust = require('../lib/dust'),
tests = require('./examples').dustExamples,
coreSetup = require('./core').coreSetup;
function dumpError(err) {
var out = err.testName + " -> ";
if (!err.message) {
err.message = JSON.stringify(err.expected)
+ " " + err.operator + " " + JSON.stringify(err.actual);
}
return out + err.stack;
}
var suite = new uutest.Suite({
pass: function() {
process.stdout.write(".");
},
fail: function(err) {
process.stdout.write("F");
},
done: function(passed, failed, elapsed) {
process.stdout.write("\n");
console.log(passed + " passed " + failed + " failed " + "(" + elapsed + "ms)");
this.errors.forEach(function(err) {
console.log(dumpError(err));
});
}
});
global.dust = dust;
coreSetup(suite, tests.slice(1));
suite.run();

104
node_modules/dust/test/uutest.js generated vendored
View File

@ -1,104 +0,0 @@
(function(uutest){
function Test(id, test, timeout, callback) {
this.id = id;
this.test = test;
this.callback = callback;
this.timeout = timeout;
}
Test.prototype.run = function() {
var self = this;
self.timer = setTimeout(function() {
self.fail(new Error("TimeoutError"));
}, self.timeout);
try {
self.test.call(self);
} catch(err) {
self.fail(err);
}
}
Test.prototype.equals = function(actual, expected, message) {
if (actual !== expected) {
var err = new Error();
if (message) err.message = message;
throw wrapAssertionError(err, actual, expected, "===");
}
}
Test.prototype.ifError = function(err) {
if (err) throw err;
}
Test.prototype.pass = function() {
clearTimeout(this.timer);
this.callback();
}
Test.prototype.fail = function(err) {
clearTimeout(this.timer);
this.callback(err);
}
uutest.Test = Test;
function Suite(options) {
this.options = options || {};
this.timeout = options.timeout || 1000;
this.tests = [];
}
Suite.prototype.test = function(name, fn) {
var self = this;
self.tests.push(new Test(name, fn, self.timeout, function(err) {
if (err) {
err.testName = name;
self.errors.push(err);
self.emit("fail", err);
} else {
self.emit("pass", name);
}
self.pending--;
self.check();
}));
}
Suite.prototype.run = function() {
if (this.pending) return;
var self = this, len = self.tests.length;
self.errors = [];
self.emit("start", self.tests);
self.start = new Date().getTime();
self.pending = len;
for (var i=0; i<len; i++) {
self.tests[i].run();
}
}
Suite.prototype.check = function() {
if (this.pending) return;
var len = this.tests.length,
passed = len - this.errors.length,
failed = len - passed;
this.emit("done", passed, failed, new Date().getTime() - this.start);
}
Suite.prototype.emit = function(type) {
var event = this.options[type];
if (event) {
event.apply(this, Array.prototype.slice.call(arguments, 1));
}
}
uutest.Suite = Suite;
function wrapAssertionError(err, actual, expected, operator) {
err.name = "AssertionError";
err.actual = actual;
err.expected = expected;
err.operator = operator;
return err;
}
})(typeof exports !== 'undefined' ? exports : window.uutest = {});

1085
node_modules/dust/vendor/beautify.js generated vendored

File diff suppressed because it is too large Load Diff

60
node_modules/dust/vendor/ecma.js generated vendored
View File

@ -1,60 +0,0 @@
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(fun /*, thisp */) {
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t)
fun.call(thisp, t[i], i, t);
}
};
}
if (!Array.prototype.map) {
Array.prototype.map = function(fun /*, thisp */) {
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t)
res[i] = fun.call(thisp, t[i], i, t);
}
return res;
};
}
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
}
if (!String.prototype.trimLeft) {
String.prototype.trimLeft = function() {
return this.replace(/^\s+/,"");
}
}
if (!String.prototype.trimRight) {
String.prototype.trimRight = function() {
return this.replace(/\s+$/,"");
}
}

93
node_modules/dust/vendor/hijs.js generated vendored
View File

@ -1,93 +0,0 @@
(function (hijs) {
//
// hijs - JavaScript Syntax Highlighter
//
// Copyright (c) 2010 Alexis Sellier
//
// All elements which match this will be syntax highlighted.
var selector = hijs || 'code';
var keywords = ('var function if else for while break switch case do new null in with void '
+'continue delete return this true false throw catch typeof with instanceof').split(' '),
special = ('eval window document undefined NaN Infinity parseInt parseFloat '
+'encodeURI decodeURI encodeURIComponent decodeURIComponent').split(' ');
// Syntax definition
// The key becomes the class name of the <span>
// around the matched block of code.
var syntax = [
['comment', /(\/\*(?:[^*\n]|\*+[^\/*])*\*+\/)/g],
['comment', /(\/\/[^\n]*)/g],
['string' , /("(?:(?!")[^\\\n]|\\.)*"|'(?:(?!')[^\\\n]|\\.)*')/g],
['regexp' , /(\/.+\/[mgi]*)(?!\s*\w)/g],
['class' , /\b([A-Z][a-zA-Z]+)\b/g],
['number' , /\b([0-9]+(?:\.[0-9]+)?)\b/g],
['keyword', new(RegExp)('\\b(' + keywords.join('|') + ')\\b', 'g')],
['special', new(RegExp)('\\b(' + special.join('|') + ')\\b', 'g')]
];
var nodes, table = {};
if (/^[a-z]+$/.test(selector)) {
nodes = document.getElementsByTagName(selector);
} else if (/^\.[\w-]+$/.test(selector)) {
nodes = document.getElementsByClassName(selector.slice(1));
} else if (document.querySelectorAll) {
nodes = document.querySelectorAll(selector);
} else {
nodes = [];
}
for (var i = 0, children; i < nodes.length; i++) {
children = nodes[i].childNodes;
for (var j = 0, str; j < children.length; j++) {
code = children[j];
if (code.length >= 0) { // It's a text node
// Don't highlight command-line snippets
if (! /^\$/.test(code.nodeValue.trim())) {
syntax.forEach(function (s) {
var k = s[0], v = s[1];
code.nodeValue = code.nodeValue.replace(v, function (_, m) {
return '\u00ab' + encode(k) + '\u00b7'
+ encode(m) +
'\u00b7' + encode(k) + '\u00bb';
});
});
}
}
}
}
for (var i = 0; i < nodes.length; i++) {
nodes[i].innerHTML =
nodes[i].innerHTML.replace(/\u00ab(.+?)\u00b7(.+?)\u00b7\1\u00bb/g, function (_, name, value) {
value = value.replace(/\u00ab[^\u00b7]+\u00b7/g, '').replace(/\u00b7[^\u00bb]+\u00bb/g, '');
return '<span class="' + decode(name) + '">' + escape(decode(value)) + '</span>';
});
}
function escape(str) {
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
// Encode ASCII characters to, and from Braille
function encode (str, encoded) {
table[encoded = str.split('').map(function (s) {
if (s.charCodeAt(0) > 127) { return s }
return String.fromCharCode(s.charCodeAt(0) + 0x2800);
}).join('')] = str;
return encoded;
}
function decode (str) {
if (str in table) {
return table[str];
} else {
return str.trim().split('').map(function (s) {
if (s.charCodeAt(0) - 0x2800 > 127) { return s }
return String.fromCharCode(s.charCodeAt(0) - 0x2800);
}).join('');
}
}
})(window.hijs);

View File

@ -1,154 +0,0 @@
/*!
* jQuery JavaScript Library v1.4.2
* http://jquery.com/
*
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2010, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Sat Feb 13 22:33:48 2010 -0500
*/
(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=
j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,
"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=
true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||
c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",
L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,
"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],
d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===
a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&
!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=
true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",
i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",
" ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=
this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=
e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=
null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=
e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,
"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=
a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,
isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=
{setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};
if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&
!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},
toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,
u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];
if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];
for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=
l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];
h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=
m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||
!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=
h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";
if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,
gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
{},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?
a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||
u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===
1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==
"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},
serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),
function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,
global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&
e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?
"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===
false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=
false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",
c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||
d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);
g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===
1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===
"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;
if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");
this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],
"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},
animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=
j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);
this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===
"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||
c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;
this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=
this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,
e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||
c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?
function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=
this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;
k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&
f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);
c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,
d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":
"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);

163
node_modules/dust/vendor/jsdump.js generated vendored
View File

@ -1,163 +0,0 @@
/**
* jsDump
* Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
* Date: 5/15/2008
* @projectDescription Advanced and extensible data dumping for Javascript.
* @version 1.0.0
* @author Ariel Flesler
* @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
*/
var jsDump;
(function(){
function quote( str ){
return '"' + str.toString().replace(/"/g, '\\"') + '"';
}
function literal( o ){
return o + '';
}
function join( pre, arr, post ){
var s = jsDump.separator(),
base = jsDump.indent(),
inner = jsDump.indent(1);
if( arr.join )
arr = arr.join( ',' + s + inner );
if( !arr )
return pre + post;
return [ pre, inner + arr, base + post ].join(s);
}
function array( arr ){
var i = arr.length, ret = Array(i);
this.up();
while( i-- )
ret[i] = this.parse( arr[i] );
this.down();
return join( '[', ret, ']' );
}
var reName = /^function (\w+)/;
jsDump = {
parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance
var parser = this.parsers[ type || this.typeOf(obj) ];
type = typeof parser;
return type == 'function' ? parser.call( this, obj ) :
type == 'string' ? parser :
this.parsers.error;
},
typeOf:function( obj ){
var type = typeof obj,
f = 'function';//we'll use it 3 times, save it
return type != 'object' && type != f ? type :
!obj ? 'null' :
obj.exec ? 'regexp' :// some browsers (FF) consider regexps functions
obj.getHours ? 'date' :
obj.scrollBy ? 'window' :
obj.nodeName == '#document' ? 'document' :
obj.nodeName ? 'node' :
obj.item ? 'nodelist' : // Safari reports nodelists as functions
obj.callee ? 'arguments' :
obj.call || obj.constructor != Array && //an array would also fall on this hack
(obj+'').indexOf(f) != -1 ? f : //IE reports functions like alert, as objects
'length' in obj ? 'array' :
type;
},
separator:function(){
return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
},
indent:function( extra ){// extra can be a number, shortcut for increasing-calling-decreasing
if( !this.multiline )
return '';
var chr = this.indentChar;
if( this.HTML )
chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
return Array( this._depth_ + (extra||0) ).join(chr);
},
up:function( a ){
this._depth_ += a || 1;
},
down:function( a ){
this._depth_ -= a || 1;
},
setParser:function( name, parser ){
this.parsers[name] = parser;
},
// The next 3 are exposed so you can use them
quote:quote,
literal:literal,
join:join,
_depth_: 1,
// This is the list of parsers, to modify them, use jsDump.setParser
parsers:{
window: '[Window]',
document: '[Document]',
error:'[ERROR]', //when no parser is found, shouldn't happen
unknown: '[Unknown]',
'null':'null',
undefined:'undefined',
'function':function( fn ){
var ret = 'function',
name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
if( name )
ret += ' ' + name;
ret += '(';
ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');
return join( ret, this.parse(fn,'functionCode'), '}' );
},
array: array,
nodelist: array,
arguments: array,
object:function( map ){
var ret = [ ];
this.up();
for( var key in map )
ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );
this.down();
return join( '{', ret, '}' );
},
node:function( node ){
var open = this.HTML ? '&lt;' : '<',
close = this.HTML ? '&gt;' : '>';
var tag = node.nodeName.toLowerCase(),
ret = open + tag;
for( var a in this.DOMAttrs ){
var val = node[this.DOMAttrs[a]];
if( val )
ret += ' ' + a + '=' + this.parse( val, 'attribute' );
}
return ret + close + open + '/' + tag + close;
},
functionArgs:function( fn ){//function calls it internally, it's the arguments part of the function
var l = fn.length;
if( !l ) return '';
var args = Array(l);
while( l-- )
args[l] = String.fromCharCode(97+l);//97 is 'a'
return ' ' + args.join(', ') + ' ';
},
key:quote, //object calls it internally, the key part of an item in a map
functionCode:'[code]', //function calls it internally, it's the content of the function
attribute:quote, //node calls it internally, it's an html attribute value
string:quote,
date:quote,
regexp:literal, //regex
number:literal,
'boolean':literal
},
DOMAttrs:{//attributes to dump from nodes, name=>realName
id:'id',
name:'name',
'class':'className'
},
HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
indentChar:' ',//indentation unit
multiline:true //if true, items in a collection, are separated by a \n, else just a space.
};
})();
if (typeof exports !== 'undefined') {
exports.jsDump = jsDump;
}

1296
node_modules/dust/vendor/showdown.js generated vendored

File diff suppressed because it is too large Load Diff

54
node_modules/dustjs-helpers/README.md generated vendored Normal file
View File

@ -0,0 +1,54 @@
# Dust Helpers [![Build Status](https://secure.travis-ci.org/linkedin/dustjs-helpers.png)](http://travis-ci.org/linkedin/dustjs-helpers)
Additional functionality for [dustjs-linkedin](http://linkedin.github.com/dustjs/) package
Read more here : <https://github.com/linkedin/dustjs-helpers>
## Getting Started
A quick tutorial for how to use Dust <https://github.com/linkedin/dustjs/wiki/Dust-Tutorial>
## Contributing
* Open https://github.com/linkedin/dustjs-helpers in a browser and fork it. Then clone your fork:
git clone https://github.com/<your github account>/dustjs-helpers dustjs-helpers
cd dustjs-helpers
* Set up a branch for what you are working on
git checkout -b myBranchName
* Install Grunt-cli, it lets you run `grunt` commands. For more information see <http://gruntjs.com/getting-started>
npm install -g grunt-cli
* Install node dependencies needed for development in this project
npm install
* Make your changes on the branch and run jshint\tests to make sure changes are OK
grunt test
* Commit your changes and push them to github
git add .
git commit -m "My changes to dustjs-helpers repo"
git push origin myBranchName
* Go to github and post a pull request, see <https://help.github.com/articles/creating-a-pull-request>
## Debugging
To debug code in a browser run `grunt dev` task. It will generate jasmine spec runner and serve it on `http://localhost:3000/_SpecRunner.html` URL.
Generated spec runner references unminified dust-helpers.js and dust-full.js files. This will allow you to easily step through the code and set up breakpoints.
This task also watches changes to lib directory, so you can simply refresh the page to see the changes without a need to re-run `grunt dev` task. Press `Ctrl + C` to disconnect from server.
## Using watch
`grunt watch` will monitor dust-helpers.js and test spec files. Whenever change is made to those files, it will jshint them and run unit tests in Phantom (will not run them in node or rhino).
It is handy way to keep testing your changes without a need to manually run `grunt testPhantom` task.
Be sure to run `grunt test` before sending pull request. It will test your change in all environments and make sure that a travis build for your pull request succeeds.
## Testing minified code in browser
Use `grunt testClient` to test prod version code in any browser. Similarly to `grunt dev` task it will host spec runner on `http://localhost:3000/_SpecRunner.html` URL.
## Coverage report
Task `grunt coverage` runs jasmine unit tests against unminified source code and generates coverage report under `tmp/coverage` folder.
Open `index.html` file in a browser to view the coverage.

19
node_modules/dustjs-helpers/dist/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2010 Aleksander Williams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

517
node_modules/dustjs-helpers/dist/dust-helpers.js generated vendored Normal file
View File

@ -0,0 +1,517 @@
/*! dustjs-helpers - v1.3.0
* https://github.com/linkedin/dustjs-helpers
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
(function(dust){
//using the built in logging method of dust when accessible
var _log = dust.log ? function(mssg) { dust.log(mssg, "INFO"); } : function() {};
function isSelect(context) {
var value = context.current();
return typeof value === "object" && value.isSelect === true;
}
// Utility method : toString() equivalent for functions
function jsonFilter(key, value) {
if (typeof value === "function") {
//to make sure all environments format functions the same way
return value.toString()
//remove all leading and trailing whitespace
.replace(/(^\s+|\s+$)/mg, '')
//remove new line characters
.replace(/\n/mg, '')
//replace , and 0 or more spaces with ", "
.replace(/,\s*/mg, ', ')
//insert space between ){
.replace(/\)\{/mg, ') {')
;
}
return value;
}
// Utility method: to invoke the given filter operation such as eq/gt etc
function filter(chunk, context, bodies, params, filterOp) {
params = params || {};
var body = bodies.block,
actualKey,
expectedValue,
filterOpType = params.filterOpType || '';
// when @eq, @lt etc are used as standalone helpers, key is required and hence check for defined
if ( typeof params.key !== "undefined") {
actualKey = dust.helpers.tap(params.key, chunk, context);
}
else if (isSelect(context)) {
actualKey = context.current().selectKey;
// supports only one of the blocks in the select to be selected
if (context.current().isResolved) {
filterOp = function() { return false; };
}
}
else {
_log("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
expectedValue = dust.helpers.tap(params.value, chunk, context);
// coerce both the actualKey and expectedValue to the same type for equality and non-equality compares
if (filterOp(coerce(expectedValue, params.type, context), coerce(actualKey, params.type, context))) {
if (isSelect(context)) {
context.current().isResolved = true;
}
// we want helpers without bodies to fail gracefully so check it first
if(body) {
return chunk.render(body, context);
}
else {
_log("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
}
else if (bodies['else']) {
return chunk.render(bodies['else'], context);
}
return chunk;
}
function coerce (value, type, context) {
if (value) {
switch (type || typeof(value)) {
case 'number': return +value;
case 'string': return String(value);
case 'boolean': {
value = (value === 'false' ? false : value);
return Boolean(value);
}
case 'date': return new Date(value);
case 'context': return context.get(value);
}
}
return value;
}
var helpers = {
// Utility helping to resolve dust references in the given chunk
// uses the Chunk.render method to resolve value
/*
Reference resolution rules:
if value exists in JSON:
"" or '' will evaluate to false, boolean false, null, or undefined will evaluate to false,
numeric 0 evaluates to true, so does, string "0", string "null", string "undefined" and string "false".
Also note that empty array -> [] is evaluated to false and empty object -> {} and non-empty object are evaluated to true
The type of the return value is string ( since we concatenate to support interpolated references
if value does not exist in JSON and the input is a single reference: {x}
dust render emits empty string, and we then return false
if values does not exist in JSON and the input is interpolated references : {x} < {y}
dust render emits < and we return the partial output
*/
"tap": function(input, chunk, context) {
// return given input if there is no dust reference to resolve
// dust compiles a string/reference such as {foo} to a function
if (typeof input !== "function") {
return input;
}
var dustBodyOutput = '',
returnValue;
//use chunk render to evaluate output. For simple functions result will be returned from render call,
//for dust body functions result will be output via callback function
returnValue = chunk.tap(function(data) {
dustBodyOutput += data;
return '';
}).render(input, context);
chunk.untap();
//assume it's a simple function call if return result is not a chunk
if (returnValue.constructor !== chunk.constructor) {
//use returnValue as a result of tap
return returnValue;
} else if (dustBodyOutput === '') {
return false;
} else {
return dustBodyOutput;
}
},
"sep": function(chunk, context, bodies) {
var body = bodies.block;
if (context.stack.index === context.stack.of - 1) {
return chunk;
}
if(body) {
return bodies.block(chunk, context);
}
else {
return chunk;
}
},
"idx": function(chunk, context, bodies) {
var body = bodies.block;
if(body) {
return bodies.block(chunk, context.push(context.stack.index));
}
else {
return chunk;
}
},
/**
* contextDump helper
* @param key specifies how much to dump.
* "current" dumps current context. "full" dumps the full context stack.
* @param to specifies where to write dump output.
* Values can be "console" or "output". Default is output.
*/
"contextDump": function(chunk, context, bodies, params) {
var p = params || {},
to = p.to || 'output',
key = p.key || 'current',
dump;
to = dust.helpers.tap(to, chunk, context);
key = dust.helpers.tap(key, chunk, context);
if (key === 'full') {
dump = JSON.stringify(context.stack, jsonFilter, 2);
}
else {
dump = JSON.stringify(context.stack.head, jsonFilter, 2);
}
if (to === 'console') {
_log(dump);
return chunk;
}
else {
return chunk.write(dump);
}
},
/**
if helper for complex evaluation complex logic expressions.
Note : #1 if helper fails gracefully when there is no body block nor else block
#2 Undefined values and false values in the JSON need to be handled specially with .length check
for e.g @if cond=" '{a}'.length && '{b}'.length" is advised when there are chances of the a and b been
undefined or false in the context
#3 Use only when the default ? and ^ dust operators and the select fall short in addressing the given logic,
since eval executes in the global scope
#4 All dust references are default escaped as they are resolved, hence eval will block malicious scripts in the context
Be mindful of evaluating a expression that is passed through the unescape filter -> |s
@param cond, either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. cond="2>3"
a dust reference is also enclosed in double quotes, e.g. cond="'{val}'' > 3"
cond argument should evaluate to a valid javascript expression
**/
"if": function( chunk, context, bodies, params ){
var body = bodies.block,
skip = bodies['else'];
if( params && params.cond){
var cond = params.cond;
cond = dust.helpers.tap(cond, chunk, context);
// eval expressions with given dust references
if(eval(cond)){
if(body) {
return chunk.render( bodies.block, context );
}
else {
_log("Missing body block in the if helper!");
return chunk;
}
}
if(skip){
return chunk.render( bodies['else'], context );
}
}
// no condition
else {
_log("No condition given in the if helper!");
}
return chunk;
},
/**
* math helper
* @param key is the value to perform math against
* @param method is the math method, is a valid string supported by math helper like mod, add, subtract
* @param operand is the second value needed for operations like mod, add, subtract, etc.
* @param round is a flag to assure that an integer is returned
*/
"math": function ( chunk, context, bodies, params ) {
//key and method are required for further processing
if( params && typeof params.key !== "undefined" && params.method ){
var key = params.key,
method = params.method,
// operand can be null for "abs", ceil and floor
operand = params.operand,
round = params.round,
mathOut = null,
operError = function(){
_log("operand is required for this math method");
return null;
};
key = dust.helpers.tap(key, chunk, context);
operand = dust.helpers.tap(operand, chunk, context);
// TODO: handle and tests for negatives and floats in all math operations
switch(method) {
case "mod":
if(operand === 0 || operand === -0) {
_log("operand for divide operation is 0/-0: expect Nan!");
}
mathOut = parseFloat(key) % parseFloat(operand);
break;
case "add":
mathOut = parseFloat(key) + parseFloat(operand);
break;
case "subtract":
mathOut = parseFloat(key) - parseFloat(operand);
break;
case "multiply":
mathOut = parseFloat(key) * parseFloat(operand);
break;
case "divide":
if(operand === 0 || operand === -0) {
_log("operand for divide operation is 0/-0: expect Nan/Infinity!");
}
mathOut = parseFloat(key) / parseFloat(operand);
break;
case "ceil":
mathOut = Math.ceil(parseFloat(key));
break;
case "floor":
mathOut = Math.floor(parseFloat(key));
break;
case "round":
mathOut = Math.round(parseFloat(key));
break;
case "abs":
mathOut = Math.abs(parseFloat(key));
break;
default:
_log("method passed is not supported");
}
if (mathOut !== null){
if (round) {
mathOut = Math.round(mathOut);
}
if (bodies && bodies.block) {
// with bodies act like the select helper with mathOut as the key
// like the select helper bodies['else'] is meaningless and is ignored
return chunk.render(bodies.block, context.push({ isSelect: true, isResolved: false, selectKey: mathOut }));
} else {
// self closing math helper will return the calculated output
return chunk.write(mathOut);
}
} else {
return chunk;
}
}
// no key parameter and no method
else {
_log("Key is a required parameter for math helper along with method/operand!");
}
return chunk;
},
/**
select helper works with one of the eq/ne/gt/gte/lt/lte/default providing the functionality
of branching conditions
@param key, ( required ) either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
**/
"select": function(chunk, context, bodies, params) {
var body = bodies.block;
// key is required for processing, hence check for defined
if( params && typeof params.key !== "undefined"){
// returns given input as output, if the input is not a dust reference, else does a context lookup
var key = dust.helpers.tap(params.key, chunk, context);
// bodies['else'] is meaningless and is ignored
if( body ) {
return chunk.render(bodies.block, context.push({ isSelect: true, isResolved: false, selectKey: key }));
}
else {
_log("Missing body block in the select helper ");
return chunk;
}
}
// no key
else {
_log("No key given in the select helper!");
}
return chunk;
},
/**
eq helper compares the given key is same as the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"eq": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "eq";
}
return filter(chunk, context, bodies, params, function(expected, actual) { return actual === expected; });
},
/**
ne helper compares the given key is not the same as the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"ne": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "ne";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual !== expected; });
}
return chunk;
},
/**
lt helper compares the given key is less than the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"lt": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "lt";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual < expected; });
}
},
/**
lte helper compares the given key is less or equal to the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"lte": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "lte";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual <= expected; });
}
return chunk;
},
/**
gt helper compares the given key is greater than the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"gt": function(chunk, context, bodies, params) {
// if no params do no go further
if(params) {
params.filterOpType = "gt";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual > expected; });
}
return chunk;
},
/**
gte helper, compares the given key is greater than or equal to the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"gte": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "gte";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual >= expected; });
}
return chunk;
},
// to be used in conjunction with the select helper
// TODO: fix the helper to do nothing when used standalone
"default": function(chunk, context, bodies, params) {
// does not require any params
if(params) {
params.filterOpType = "default";
}
return filter(chunk, context, bodies, params, function(expected, actual) { return true; });
},
/**
* size helper prints the size of the given key
* Note : size helper is self closing and does not support bodies
* @param key, the element whose size is returned
*/
"size": function( chunk, context, bodies, params ) {
var key, value=0, nr, k;
params = params || {};
key = params.key;
if (!key || key === true) { //undefined, null, "", 0
value = 0;
}
else if(dust.isArray(key)) { //array
value = key.length;
}
else if (!isNaN(parseFloat(key)) && isFinite(key)) { //numeric values
value = key;
}
else if (typeof key === "object") { //object test
//objects, null and array all have typeof ojbect...
//null and array are already tested so typeof is sufficient http://jsperf.com/isobject-tests
nr = 0;
for(k in key){
if(Object.hasOwnProperty.call(key,k)){
nr++;
}
}
value = nr;
} else {
value = (key + '').length; //any other value (strings etc.)
}
return chunk.write(value);
}
};
for (var key in helpers) {
dust.helpers[key] = helpers[key];
}
if(typeof exports !== 'undefined') {
module.exports = dust;
}
})(typeof exports !== 'undefined' ? require('dustjs-linkedin') : dust);

4
node_modules/dustjs-helpers/dist/dust-helpers.min.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
/*! dustjs-helpers - v1.3.0
* https://github.com/linkedin/dustjs-helpers
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
!function(dust){function isSelect(a){var b=a.current();return"object"==typeof b&&b.isSelect===!0}function jsonFilter(a,b){return"function"==typeof b?b.toString().replace(/(^\s+|\s+$)/gm,"").replace(/\n/gm,"").replace(/,\s*/gm,", ").replace(/\)\{/gm,") {"):b}function filter(a,b,c,d,e){d=d||{};var f,g,h=c.block,i=d.filterOpType||"";if("undefined"!=typeof d.key)f=dust.helpers.tap(d.key,a,b);else{if(!isSelect(b))return _log("No key specified for filter in:"+i+" helper "),a;f=b.current().selectKey,b.current().isResolved&&(e=function(){return!1})}return g=dust.helpers.tap(d.value,a,b),e(coerce(g,d.type,b),coerce(f,d.type,b))?(isSelect(b)&&(b.current().isResolved=!0),h?a.render(h,b):(_log("No key specified for filter in:"+i+" helper "),a)):c["else"]?a.render(c["else"],b):a}function coerce(a,b,c){if(a)switch(b||typeof a){case"number":return+a;case"string":return String(a);case"boolean":return a="false"===a?!1:a,Boolean(a);case"date":return new Date(a);case"context":return c.get(a)}return a}var _log=dust.log?function(a){dust.log(a,"INFO")}:function(){},helpers={tap:function(a,b,c){if("function"!=typeof a)return a;var d,e="";return d=b.tap(function(a){return e+=a,""}).render(a,c),b.untap(),d.constructor!==b.constructor?d:""===e?!1:e},sep:function(a,b,c){var d=c.block;return b.stack.index===b.stack.of-1?a:d?c.block(a,b):a},idx:function(a,b,c){var d=c.block;return d?c.block(a,b.push(b.stack.index)):a},contextDump:function(a,b,c,d){var e,f=d||{},g=f.to||"output",h=f.key||"current";return g=dust.helpers.tap(g,a,b),h=dust.helpers.tap(h,a,b),e="full"===h?JSON.stringify(b.stack,jsonFilter,2):JSON.stringify(b.stack.head,jsonFilter,2),"console"===g?(_log(e),a):a.write(e)},"if":function(chunk,context,bodies,params){var body=bodies.block,skip=bodies["else"];if(params&&params.cond){var cond=params.cond;if(cond=dust.helpers.tap(cond,chunk,context),eval(cond))return body?chunk.render(bodies.block,context):(_log("Missing body block in the if helper!"),chunk);if(skip)return chunk.render(bodies["else"],context)}else _log("No condition given in the if helper!");return chunk},math:function(a,b,c,d){if(d&&"undefined"!=typeof d.key&&d.method){var e=d.key,f=d.method,g=d.operand,h=d.round,i=null;switch(e=dust.helpers.tap(e,a,b),g=dust.helpers.tap(g,a,b),f){case"mod":(0===g||g===-0)&&_log("operand for divide operation is 0/-0: expect Nan!"),i=parseFloat(e)%parseFloat(g);break;case"add":i=parseFloat(e)+parseFloat(g);break;case"subtract":i=parseFloat(e)-parseFloat(g);break;case"multiply":i=parseFloat(e)*parseFloat(g);break;case"divide":(0===g||g===-0)&&_log("operand for divide operation is 0/-0: expect Nan/Infinity!"),i=parseFloat(e)/parseFloat(g);break;case"ceil":i=Math.ceil(parseFloat(e));break;case"floor":i=Math.floor(parseFloat(e));break;case"round":i=Math.round(parseFloat(e));break;case"abs":i=Math.abs(parseFloat(e));break;default:_log("method passed is not supported")}return null!==i?(h&&(i=Math.round(i)),c&&c.block?a.render(c.block,b.push({isSelect:!0,isResolved:!1,selectKey:i})):a.write(i)):a}return _log("Key is a required parameter for math helper along with method/operand!"),a},select:function(a,b,c,d){var e=c.block;if(d&&"undefined"!=typeof d.key){var f=dust.helpers.tap(d.key,a,b);return e?a.render(c.block,b.push({isSelect:!0,isResolved:!1,selectKey:f})):(_log("Missing body block in the select helper "),a)}return _log("No key given in the select helper!"),a},eq:function(a,b,c,d){return d&&(d.filterOpType="eq"),filter(a,b,c,d,function(a,b){return b===a})},ne:function(a,b,c,d){return d?(d.filterOpType="ne",filter(a,b,c,d,function(a,b){return b!==a})):a},lt:function(a,b,c,d){return d?(d.filterOpType="lt",filter(a,b,c,d,function(a,b){return a>b})):void 0},lte:function(a,b,c,d){return d?(d.filterOpType="lte",filter(a,b,c,d,function(a,b){return a>=b})):a},gt:function(a,b,c,d){return d?(d.filterOpType="gt",filter(a,b,c,d,function(a,b){return b>a})):a},gte:function(a,b,c,d){return d?(d.filterOpType="gte",filter(a,b,c,d,function(a,b){return b>=a})):a},"default":function(a,b,c,d){return d&&(d.filterOpType="default"),filter(a,b,c,d,function(){return!0})},size:function(a,b,c,d){var e,f,g,h=0;if(d=d||{},e=d.key,e&&e!==!0)if(dust.isArray(e))h=e.length;else if(!isNaN(parseFloat(e))&&isFinite(e))h=e;else if("object"==typeof e){f=0;for(g in e)Object.hasOwnProperty.call(e,g)&&f++;h=f}else h=(e+"").length;else h=0;return a.write(h)}};for(var key in helpers)dust.helpers[key]=helpers[key];"undefined"!=typeof exports&&(module.exports=dust)}("undefined"!=typeof exports?require("dustjs-linkedin"):dust);

514
node_modules/dustjs-helpers/lib/dust-helpers.js generated vendored Normal file
View File

@ -0,0 +1,514 @@
(function(dust){
//using the built in logging method of dust when accessible
var _log = dust.log ? function(mssg) { dust.log(mssg, "INFO"); } : function() {};
function isSelect(context) {
var value = context.current();
return typeof value === "object" && value.isSelect === true;
}
// Utility method : toString() equivalent for functions
function jsonFilter(key, value) {
if (typeof value === "function") {
//to make sure all environments format functions the same way
return value.toString()
//remove all leading and trailing whitespace
.replace(/(^\s+|\s+$)/mg, '')
//remove new line characters
.replace(/\n/mg, '')
//replace , and 0 or more spaces with ", "
.replace(/,\s*/mg, ', ')
//insert space between ){
.replace(/\)\{/mg, ') {')
;
}
return value;
}
// Utility method: to invoke the given filter operation such as eq/gt etc
function filter(chunk, context, bodies, params, filterOp) {
params = params || {};
var body = bodies.block,
actualKey,
expectedValue,
filterOpType = params.filterOpType || '';
// when @eq, @lt etc are used as standalone helpers, key is required and hence check for defined
if ( typeof params.key !== "undefined") {
actualKey = dust.helpers.tap(params.key, chunk, context);
}
else if (isSelect(context)) {
actualKey = context.current().selectKey;
// supports only one of the blocks in the select to be selected
if (context.current().isResolved) {
filterOp = function() { return false; };
}
}
else {
_log("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
expectedValue = dust.helpers.tap(params.value, chunk, context);
// coerce both the actualKey and expectedValue to the same type for equality and non-equality compares
if (filterOp(coerce(expectedValue, params.type, context), coerce(actualKey, params.type, context))) {
if (isSelect(context)) {
context.current().isResolved = true;
}
// we want helpers without bodies to fail gracefully so check it first
if(body) {
return chunk.render(body, context);
}
else {
_log("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
}
else if (bodies['else']) {
return chunk.render(bodies['else'], context);
}
return chunk;
}
function coerce (value, type, context) {
if (value) {
switch (type || typeof(value)) {
case 'number': return +value;
case 'string': return String(value);
case 'boolean': {
value = (value === 'false' ? false : value);
return Boolean(value);
}
case 'date': return new Date(value);
case 'context': return context.get(value);
}
}
return value;
}
var helpers = {
// Utility helping to resolve dust references in the given chunk
// uses the Chunk.render method to resolve value
/*
Reference resolution rules:
if value exists in JSON:
"" or '' will evaluate to false, boolean false, null, or undefined will evaluate to false,
numeric 0 evaluates to true, so does, string "0", string "null", string "undefined" and string "false".
Also note that empty array -> [] is evaluated to false and empty object -> {} and non-empty object are evaluated to true
The type of the return value is string ( since we concatenate to support interpolated references
if value does not exist in JSON and the input is a single reference: {x}
dust render emits empty string, and we then return false
if values does not exist in JSON and the input is interpolated references : {x} < {y}
dust render emits < and we return the partial output
*/
"tap": function(input, chunk, context) {
// return given input if there is no dust reference to resolve
// dust compiles a string/reference such as {foo} to a function
if (typeof input !== "function") {
return input;
}
var dustBodyOutput = '',
returnValue;
//use chunk render to evaluate output. For simple functions result will be returned from render call,
//for dust body functions result will be output via callback function
returnValue = chunk.tap(function(data) {
dustBodyOutput += data;
return '';
}).render(input, context);
chunk.untap();
//assume it's a simple function call if return result is not a chunk
if (returnValue.constructor !== chunk.constructor) {
//use returnValue as a result of tap
return returnValue;
} else if (dustBodyOutput === '') {
return false;
} else {
return dustBodyOutput;
}
},
"sep": function(chunk, context, bodies) {
var body = bodies.block;
if (context.stack.index === context.stack.of - 1) {
return chunk;
}
if(body) {
return bodies.block(chunk, context);
}
else {
return chunk;
}
},
"idx": function(chunk, context, bodies) {
var body = bodies.block;
if(body) {
return bodies.block(chunk, context.push(context.stack.index));
}
else {
return chunk;
}
},
/**
* contextDump helper
* @param key specifies how much to dump.
* "current" dumps current context. "full" dumps the full context stack.
* @param to specifies where to write dump output.
* Values can be "console" or "output". Default is output.
*/
"contextDump": function(chunk, context, bodies, params) {
var p = params || {},
to = p.to || 'output',
key = p.key || 'current',
dump;
to = dust.helpers.tap(to, chunk, context);
key = dust.helpers.tap(key, chunk, context);
if (key === 'full') {
dump = JSON.stringify(context.stack, jsonFilter, 2);
}
else {
dump = JSON.stringify(context.stack.head, jsonFilter, 2);
}
if (to === 'console') {
_log(dump);
return chunk;
}
else {
return chunk.write(dump);
}
},
/**
if helper for complex evaluation complex logic expressions.
Note : #1 if helper fails gracefully when there is no body block nor else block
#2 Undefined values and false values in the JSON need to be handled specially with .length check
for e.g @if cond=" '{a}'.length && '{b}'.length" is advised when there are chances of the a and b been
undefined or false in the context
#3 Use only when the default ? and ^ dust operators and the select fall short in addressing the given logic,
since eval executes in the global scope
#4 All dust references are default escaped as they are resolved, hence eval will block malicious scripts in the context
Be mindful of evaluating a expression that is passed through the unescape filter -> |s
@param cond, either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. cond="2>3"
a dust reference is also enclosed in double quotes, e.g. cond="'{val}'' > 3"
cond argument should evaluate to a valid javascript expression
**/
"if": function( chunk, context, bodies, params ){
var body = bodies.block,
skip = bodies['else'];
if( params && params.cond){
var cond = params.cond;
cond = dust.helpers.tap(cond, chunk, context);
// eval expressions with given dust references
if(eval(cond)){
if(body) {
return chunk.render( bodies.block, context );
}
else {
_log("Missing body block in the if helper!");
return chunk;
}
}
if(skip){
return chunk.render( bodies['else'], context );
}
}
// no condition
else {
_log("No condition given in the if helper!");
}
return chunk;
},
/**
* math helper
* @param key is the value to perform math against
* @param method is the math method, is a valid string supported by math helper like mod, add, subtract
* @param operand is the second value needed for operations like mod, add, subtract, etc.
* @param round is a flag to assure that an integer is returned
*/
"math": function ( chunk, context, bodies, params ) {
//key and method are required for further processing
if( params && typeof params.key !== "undefined" && params.method ){
var key = params.key,
method = params.method,
// operand can be null for "abs", ceil and floor
operand = params.operand,
round = params.round,
mathOut = null,
operError = function(){
_log("operand is required for this math method");
return null;
};
key = dust.helpers.tap(key, chunk, context);
operand = dust.helpers.tap(operand, chunk, context);
// TODO: handle and tests for negatives and floats in all math operations
switch(method) {
case "mod":
if(operand === 0 || operand === -0) {
_log("operand for divide operation is 0/-0: expect Nan!");
}
mathOut = parseFloat(key) % parseFloat(operand);
break;
case "add":
mathOut = parseFloat(key) + parseFloat(operand);
break;
case "subtract":
mathOut = parseFloat(key) - parseFloat(operand);
break;
case "multiply":
mathOut = parseFloat(key) * parseFloat(operand);
break;
case "divide":
if(operand === 0 || operand === -0) {
_log("operand for divide operation is 0/-0: expect Nan/Infinity!");
}
mathOut = parseFloat(key) / parseFloat(operand);
break;
case "ceil":
mathOut = Math.ceil(parseFloat(key));
break;
case "floor":
mathOut = Math.floor(parseFloat(key));
break;
case "round":
mathOut = Math.round(parseFloat(key));
break;
case "abs":
mathOut = Math.abs(parseFloat(key));
break;
default:
_log("method passed is not supported");
}
if (mathOut !== null){
if (round) {
mathOut = Math.round(mathOut);
}
if (bodies && bodies.block) {
// with bodies act like the select helper with mathOut as the key
// like the select helper bodies['else'] is meaningless and is ignored
return chunk.render(bodies.block, context.push({ isSelect: true, isResolved: false, selectKey: mathOut }));
} else {
// self closing math helper will return the calculated output
return chunk.write(mathOut);
}
} else {
return chunk;
}
}
// no key parameter and no method
else {
_log("Key is a required parameter for math helper along with method/operand!");
}
return chunk;
},
/**
select helper works with one of the eq/ne/gt/gte/lt/lte/default providing the functionality
of branching conditions
@param key, ( required ) either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
**/
"select": function(chunk, context, bodies, params) {
var body = bodies.block;
// key is required for processing, hence check for defined
if( params && typeof params.key !== "undefined"){
// returns given input as output, if the input is not a dust reference, else does a context lookup
var key = dust.helpers.tap(params.key, chunk, context);
// bodies['else'] is meaningless and is ignored
if( body ) {
return chunk.render(bodies.block, context.push({ isSelect: true, isResolved: false, selectKey: key }));
}
else {
_log("Missing body block in the select helper ");
return chunk;
}
}
// no key
else {
_log("No key given in the select helper!");
}
return chunk;
},
/**
eq helper compares the given key is same as the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"eq": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "eq";
}
return filter(chunk, context, bodies, params, function(expected, actual) { return actual === expected; });
},
/**
ne helper compares the given key is not the same as the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"ne": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "ne";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual !== expected; });
}
return chunk;
},
/**
lt helper compares the given key is less than the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"lt": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "lt";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual < expected; });
}
},
/**
lte helper compares the given key is less or equal to the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"lte": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "lte";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual <= expected; });
}
return chunk;
},
/**
gt helper compares the given key is greater than the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"gt": function(chunk, context, bodies, params) {
// if no params do no go further
if(params) {
params.filterOpType = "gt";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual > expected; });
}
return chunk;
},
/**
gte helper, compares the given key is greater than or equal to the expected value
It can be used standalone or in conjunction with select for multiple branching
@param key, The actual key to be compared ( optional when helper used in conjunction with select)
either a string literal value or a dust reference
a string literal value, is enclosed in double quotes, e.g. key="foo"
a dust reference may or may not be enclosed in double quotes, e.g. key="{val}" and key=val are both valid
@param value, The expected value to compare to, when helper is used standalone or in conjunction with select
@param type (optional), supported types are number, boolean, string, date, context, defaults to string
Note : use type="number" when comparing numeric
**/
"gte": function(chunk, context, bodies, params) {
if(params) {
params.filterOpType = "gte";
return filter(chunk, context, bodies, params, function(expected, actual) { return actual >= expected; });
}
return chunk;
},
// to be used in conjunction with the select helper
// TODO: fix the helper to do nothing when used standalone
"default": function(chunk, context, bodies, params) {
// does not require any params
if(params) {
params.filterOpType = "default";
}
return filter(chunk, context, bodies, params, function(expected, actual) { return true; });
},
/**
* size helper prints the size of the given key
* Note : size helper is self closing and does not support bodies
* @param key, the element whose size is returned
*/
"size": function( chunk, context, bodies, params ) {
var key, value=0, nr, k;
params = params || {};
key = params.key;
if (!key || key === true) { //undefined, null, "", 0
value = 0;
}
else if(dust.isArray(key)) { //array
value = key.length;
}
else if (!isNaN(parseFloat(key)) && isFinite(key)) { //numeric values
value = key;
}
else if (typeof key === "object") { //object test
//objects, null and array all have typeof ojbect...
//null and array are already tested so typeof is sufficient http://jsperf.com/isobject-tests
nr = 0;
for(k in key){
if(Object.hasOwnProperty.call(key,k)){
nr++;
}
}
value = nr;
} else {
value = (key + '').length; //any other value (strings etc.)
}
return chunk.write(value);
}
};
for (var key in helpers) {
dust.helpers[key] = helpers[key];
}
if(typeof exports !== 'undefined') {
module.exports = dust;
}
})(typeof exports !== 'undefined' ? require('dustjs-linkedin') : dust);

115
node_modules/dustjs-helpers/package.json generated vendored Normal file
View File

@ -0,0 +1,115 @@
{
"name": "dustjs-helpers",
"version": "1.3.0",
"author": {
"name": "Aleksander Williams",
"url": "http://akdubya.github.com/dustjs"
},
"homepage": "https://github.com/linkedin/dustjs-helpers",
"description": "Helpers for dustjs-linkedin package",
"contributors": [
{
"name": "Jairo de Morais",
"email": "jdemorais@linkedin.com"
},
{
"name": "Yevgeniy Brikman",
"email": "jbrikman@linkedin.com"
},
{
"name": "Veena Basavaraj",
"email": "vbasavaraj@linkedin.com"
},
{
"name": "Johnathan Leppert",
"email": "jleppert@linkedin.com"
},
{
"name": "Jimmy Chan",
"email": "jchan@linkedin.com"
},
{
"name": "Richard Ragan",
"email": "rragan@ebay.com"
},
{
"name": "Sarah Clatterbuck",
"email": "sclatter@linkedin.com"
},
{
"name": "Kate Odnous",
"email": "kodnous@linkedin.com"
}
],
"scripts": {
"test": "grunt test"
},
"main": "./lib/dust-helpers",
"repository": {
"type": "git",
"url": "https://github.com/linkedin/dustjs-helpers.git"
},
"keywords": [
"templates",
"views",
"helpers"
],
"peerDependencies": {
"dustjs-linkedin": "~2.4.0"
},
"devDependencies": {
"dustjs-linkedin": "~2.4.0",
"jasmine-node": "~1.13.0",
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-template-jasmine-istanbul": "~0.2.5",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-uglify": "~0.3.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-compress": "~0.6.0",
"grunt-bump": "~0.0.13",
"grunt-shell": "~0.6.3"
},
"license": "MIT",
"engine": {
"node": ">=0.8"
},
"bugs": {
"url": "https://github.com/linkedin/dustjs-helpers/issues"
},
"_id": "dustjs-helpers@1.3.0",
"dist": {
"shasum": "38149f6733d90e6ea66fffe34d981eefacccb492",
"tarball": "http://registry.npmjs.org/dustjs-helpers/-/dustjs-helpers-1.3.0.tgz"
},
"_from": "dustjs-helpers@1.3.0",
"_npmVersion": "1.4.3",
"_npmUser": {
"name": "linkedin",
"email": "acrabtree@linkedin.com"
},
"maintainers": [
{
"name": "vybs",
"email": "veena.braj@gmail.com"
},
{
"name": "rragan",
"email": "rragan@ebay.com"
},
{
"name": "jimmyhchan",
"email": "jimmyhchan@gmail.com"
},
{
"name": "linkedin",
"email": "acrabtree@linkedin.com"
}
],
"directories": {},
"_shasum": "38149f6733d90e6ea66fffe34d981eefacccb492",
"_resolved": "https://registry.npmjs.org/dustjs-helpers/-/dustjs-helpers-1.3.0.tgz"
}

11
node_modules/dustjs-linkedin/.npmignore generated vendored Normal file
View File

@ -0,0 +1,11 @@
.grunt
.jshintrc
.travis.yml
_SpecRunner.html
Gruntfile.js
benchmark
docs
src
tmp
test
archive

174
node_modules/dustjs-linkedin/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,174 @@
## Change Log
### v2.4.0 (2014/06/11 01:32 +00:00)
- [#470](https://github.com/linkedin/dustjs/pull/470) Ensure client bundlers load only client-side code (@patrick-steele-idem)
- [#474](https://github.com/linkedin/dustjs/pull/474) travis build fix for minimatch grunt module (@prashn64)
- [#475](https://github.com/linkedin/dustjs/pull/475) remove config set on before install for travis build (@prashn64)
- [#471](https://github.com/linkedin/dustjs/pull/471) Errors thrown from render will now call populate the error in the callback. Previously, thrown errors will immediately fail and not call the callback. Issue #381,
Address #468: Errors thrown from stream now will invoke the `error` listener with the error object. Previously, these errors could not be caught and the process will hang.
Deprecated/remove: `dust.onError`, `dust.silenceErrors`. To see runtime errors, look at the error in the callback.
breaking change: `dust.log` with an error no longer throws that error (@prashn64)
- [#424](https://github.com/linkedin/dustjs/pull/424) Set up dev flow with grunt and fix coverage report (@kate2753)
- [#447](https://github.com/linkedin/dustjs/pull/447) deprecate the internal property context.isFunction. this is no longer needed. (@prashn64)
- [#441](https://github.com/linkedin/dustjs/pull/441) Make default params type to an object instead of github.com (@prashn64)
- [#472](https://github.com/linkedin/dustjs/pull/472) #469 Prevent references from looking in the prototype.
Previously, {arr.sort} was possible even if sort was not a function in the arr object, since it was looking in the Array prototype. (@jimmyhchan)
### v2.3.5 (2014/05/08 21:31 +00:00)
- [#463](https://github.com/linkedin/dustjs/pull/463) Rendering performance improvements by simplifying logging (@prashn64)
### v2.3.4 (2014/03/06 22:34 +00:00)
- [#435](https://github.com/linkedin/dustjs/pull/435) indexInArray fix. (@prashn64)
### v2.3.3 (2014/01/31 21:29 +00:00)
- [#416](https://github.com/linkedin/dustjs/pull/416) Lower most errors to warnings. (@prashn64)
### v2.3.2 (2014/01/28 01:12 +00:00)
- [#414](https://github.com/linkedin/dustjs/pull/414) Point dustc to the correct version of server dust (@jimmyhchan)
### v2.3.1 (2014/01/19 22:23 +00:00)
- [#408](https://github.com/linkedin/dustjs/pull/408) dust.compileFn no longer requires the name to be defined. (@jimmyhchan)
### v2.3.0 (2014/01/17 00:26 +00:00)
- [#399](https://github.com/linkedin/dustjs/pull/399) Don't swallow all errors by default (Issue #381). Deprecate dust.isDebug and dust.onError. Instead, just use debugLevel and dust.log(message, 'ERROR'), respectively. Add a dust.silenceErrors flag to swallow all errors. (@prashn64)
- [#395](https://github.com/linkedin/dustjs/pull/395) fail hard when a name is not explicitly defined in dust.compile (@prashn64)
- [#403](https://github.com/linkedin/dustjs/pull/403) bump commit does not support tasks (@jimmyhchan)
- [#404](https://github.com/linkedin/dustjs/pull/404) revert package.json back to 2.2.3 (@prashn64)
- [#392](https://github.com/linkedin/dustjs/pull/392) Add Rhino and Rhino unit tests (@kate2753)
- [#405](https://github.com/linkedin/dustjs/pull/405) Fix Grunt release and don't push upstream by default (safer) (@jimmyhchan)
### v2.2.10 (2014/05/07 23:39 +00:00)
- [#444](https://github.com/linkedin/dustjs/pull/444) make console.log available for logging statements in node environment by passing the proper global (@bgmort)
### v2.2.7 (2014/02/24 23:06 +00:00)
- [#419](https://github.com/linkedin/dustjs/pull/419) Fix Context.prototype._get to work with context switching when calling partials and make the 2.2.x+ compiler fully backwards compatible. (@kate2753)
### v2.2.6 (2014/02/13 00:18 +00:00)
- [#420](https://github.com/linkedin/dustjs/pull/420) Make the compiler backwards compatible with runtime versions prior to 2.2.x (@kate2753)
### v2.2.3 (2013/12/06 02:02 +00:00)
- [#372](https://github.com/linkedin/dustjs/pull/372) Regenerate dist files for v2.2.3 to include $idx fixes (@kate2753)
- [#374](https://github.com/linkedin/dustjs/pull/374) Properly generate .min files for 2.2.3 (@kate2753)
### v2.2.2 (2013/11/28 00:10 +00:00)
- [#362](https://github.com/linkedin/dustjs/pull/362) remove node_modules directory (@wizardzloy)
- [#363](https://github.com/linkedin/dustjs/pull/363) Issue #340. Remove old optimization to avoid looking at arrays in get. (@rragan)
- [#368](https://github.com/linkedin/dustjs/pull/368) Add context.getTemplateName. This method now correctly returns the template name even for directly loaded templates being used as partials. For end users please use this api for getting the template name instead of ctx.templatename (@prashn64)
### v2.2.0 (2013/11/08 18:42 +00:00)
- [#360](https://github.com/linkedin/dustjs/pull/360) Use get for all Dust references (@smfoote)
### v2.1.4 (2014/03/06 00:32 +00:00)
- [#429](https://github.com/linkedin/dustjs/pull/429) Patch 2.1.X 2.2.X 2.3.X to fix IE9 and below issues when dust debugging is on. Added a cross-browser/node/rhino version of indexOf and logger.log. (@prashn64)
- [#430](https://github.com/linkedin/dustjs/pull/430) Only have the logger.log call once inside logger.log (@prashn64)
- [#432](https://github.com/linkedin/dustjs/pull/432) add temporary fix for ssl problems with npm until travis itself updates ... (@prashn64)
### v2.1.3 (2014/02/27 08:18 +00:00)
- [#427](https://github.com/linkedin/dustjs/pull/427) Add 2.2.7 which is identical to 2.2.6 for npm (@prashn64)
- [#426](https://github.com/linkedin/dustjs/pull/426) Add changelog (@lalitkapoor)
### v2.1.1 (2014/01/16 01:09 +00:00)
- [#371](https://github.com/linkedin/dustjs/pull/371) Fix our release process + add bower.json + jshint + cleanup master (@jimmyhchan)
- [#334](https://github.com/linkedin/dustjs/pull/334) Issue #332 provide a raw input syntax similar to comments {!...!} where newlines, spaces and braces are kept. (@jimmyhchan)
- [#382](https://github.com/linkedin/dustjs/pull/382) remove the globals and isolate parser and compiler (@jimmyhchan)
### v2.1.0 (2013/10/25 08:44 +00:00)
- [#279](https://github.com/linkedin/dustjs/pull/279) Client Side Debugging (@prashn64)
- [#344](https://github.com/linkedin/dustjs/pull/344) Per discussions, this may be a bit premature. Revert "Merge pull request #279 from prashn64/master" until the api for debugging is more settled. (@prashn64)
- [#347](https://github.com/linkedin/dustjs/pull/347) Dust error logging (@prashn64)
- [#355](https://github.com/linkedin/dustjs/pull/355) add a unit test for inline params with dashes (@prashn64)
- [#350](https://github.com/linkedin/dustjs/pull/350) Support dynamic template names for the context's template name. (@johnsonlei)
### v2.0.3 (2013/09/06 23:23 +00:00)
- [#323](https://github.com/linkedin/dustjs/pull/323) Fix Issue #322. block name in template includes previous text by mistake (@rragan)
- [#328](https://github.com/linkedin/dustjs/pull/328) Put templateName on the context instance instead of the context's globals. (@prashn64)
- [#335](https://github.com/linkedin/dustjs/pull/335) make context.templateName change into version 2.0.3 (@prashn64)
- [#338](https://github.com/linkedin/dustjs/pull/338) update to correct 2.0.3 (@prashn64)
### v2.0.2 (2013/08/01 20:57 +00:00)
- [#318](https://github.com/linkedin/dustjs/pull/318) Fix issue #317. Falsey value at end of path (@rragan)
- [#319](https://github.com/linkedin/dustjs/pull/319) Clarify comments on path search (@rragan)
- [#320](https://github.com/linkedin/dustjs/pull/320) Update parser.js to sync with latest dust.pegjs (@smfoote)
### v2.0.1 (2013/07/24 17:34 +00:00)
- [#312](https://github.com/linkedin/dustjs/pull/312) Remove node_modules/jasmine_node (@smfoote)
- [#309](https://github.com/linkedin/dustjs/pull/309) Add lines and columns to dust.pegjs (@smfoote)
### v2.0.0 (2013/07/17 02:18 +00:00)
- [#2](https://github.com/linkedin/dustjs/pull/2) Fixed jasmine testRunner to understand base and options properties (@rragan)
- [#271](https://github.com/linkedin/dustjs/pull/271) adding support for . path resolution in context get (@carchrae, @rragan)
- [#289](https://github.com/linkedin/dustjs/pull/289) Cache VM context across `dust.loadSource` calls. (@totherik)
- [#304](https://github.com/linkedin/dustjs/pull/304) GH-292 support template name in nested partials, need a stack to store the current name (@vybs)
- [#305](https://github.com/linkedin/dustjs/pull/305) Remove option to control pathScope and remove tests for old getPath (@rragan)
- [#306](https://github.com/linkedin/dustjs/pull/306) add support for GH-292, support the template name in nested partials (@vybs)
### v1.2.6 (2013/06/06 15:54 +00:00)
- [#278](https://github.com/linkedin/dustjs/pull/278) Remove strip from dust.compile, since it wasn't really very good anyway (@smfoote)
### v1.2.5 (2013/06/02 21:25 +00:00)
- [#25](https://github.com/linkedin/dustjs/pull/25) process.binding('evals') is now require('vm') (@stonecobra)
- [#3](https://github.com/linkedin/dustjs/pull/3) Gaurd against browsers (@Raynos)
- [#5](https://github.com/linkedin/dustjs/pull/5) Quote 'if' helper, fixes #4 (@kmiyashiro)
- [#9](https://github.com/linkedin/dustjs/pull/9) Update to 0.4.0 in dist so that docs are correct (@kmiyashiro)
- [#25](https://github.com/linkedin/dustjs/pull/25) pegjs 0.7 compatibility and parser variables removed from section function on dustjs file (@jairodemorais)
- [#13](https://github.com/linkedin/dustjs/pull/13) Issue #8 Support cleaner way to pass arguments to partials (@jimmyhchan)
- [#36](https://github.com/linkedin/dustjs/pull/36) Rhino compatible (@jairodemorais)
- [#34](https://github.com/linkedin/dustjs/pull/34) Escape a single quote apostrophe in escapeHtml (@iamleppert)
- [#31](https://github.com/linkedin/dustjs/pull/31) process.nextTick instead of setTimeout (@zaphod1984)
- [#39](https://github.com/linkedin/dustjs/pull/39) Fixes #28, better error tracking implemented. (@iamleppert)
- [#37](https://github.com/linkedin/dustjs/pull/37) Fixes #7, "Support numbers in the aliases" (@iamleppert)
- [#40](https://github.com/linkedin/dustjs/pull/40) Rebuilding parser and merge to fix failed CI (@iamleppert)
- [#49](https://github.com/linkedin/dustjs/pull/49) dust tool included. (@jairodemorais)
- [#44](https://github.com/linkedin/dustjs/pull/44) Select helper and unit tests, fixes #16 (@iamleppert)
- [#52](https://github.com/linkedin/dustjs/pull/52) Added unit test code coverage report with node-coverage (@iamleppert)
- [#54](https://github.com/linkedin/dustjs/pull/54) preventing dust to crash on non existant if-condition (@zaphod1984)
- [#59](https://github.com/linkedin/dustjs/pull/59) ws relaxed to allow eol (@jairodemorais)
- [#60](https://github.com/linkedin/dustjs/pull/60) dust moved to 0.6.0 version (@jairodemorais)
- [#56](https://github.com/linkedin/dustjs/pull/56) Fix for Issue #50: helper for debugging the context + console log wrapper (@jimmyhchan)
- [#71](https://github.com/linkedin/dustjs/pull/71) Test for pipe function added. (@jairodemorais, @kilianc)
- [#73](https://github.com/linkedin/dustjs/pull/73) dust resolve reference helper created and refactor if to use it (@jairodemorais)
- [#70](https://github.com/linkedin/dustjs/pull/70) fix issue https://github.com/linkedin/dustjs/issues/68 (@jairodemorais)
- [#65](https://github.com/linkedin/dustjs/pull/65) literal params relaxed to allow eol (@jairodemorais)
- [#78](https://github.com/linkedin/dustjs/pull/78) Use the tap method in the select helper (@jairodemorais)
- [#95](https://github.com/linkedin/dustjs/pull/95) helpers removed from Dust core. New npm package created for helpers. (@jairodemorais)
- [#105](https://github.com/linkedin/dustjs/pull/105) merge PR https://github.com/linkedin/dustjs/pull/93 (@jairodemorais)
- [#113](https://github.com/linkedin/dustjs/pull/113) Make $idx/$len work for all array objects and not leave old values in contexts (@rragan)
- [#99](https://github.com/linkedin/dustjs/pull/99) new math helper method (@sclatter)
- [#126](https://github.com/linkedin/dustjs/pull/126) Removed left-over .DS_Store files (@zzen)
- [#128](https://github.com/linkedin/dustjs/pull/128) Updated README for consistency and readability (@zzen)
- [#108](https://github.com/linkedin/dustjs/pull/108) issue 106, accessing array inside a loop using the current context (@jairodemorais)
- [#132](https://github.com/linkedin/dustjs/pull/132) Partial with parameters was not getting the correct context (@jimmyhchan)
- [#127](https://github.com/linkedin/dustjs/pull/127) Fixed :else in section when iterating over empty array. (@zzen)
- [#139](https://github.com/linkedin/dustjs/pull/139) GH-85, GH-127 improve test coverage (@vybs)
- [#140](https://github.com/linkedin/dustjs/pull/140) GH-134 , remove support for scalar in the block # (@vybs)
- [#141](https://github.com/linkedin/dustjs/pull/141) Fixes for GH-134 (@vybs)
- [#142](https://github.com/linkedin/dustjs/pull/142) add another intersting test case with . and blocks (@vybs)
- [#143](https://github.com/linkedin/dustjs/pull/143) reverse the GH-134 since it is backward incompatible (@vybs)
- [#144](https://github.com/linkedin/dustjs/pull/144) minor: reorganized the section code and documented some more as to how t... (@vybs)
- [#145](https://github.com/linkedin/dustjs/pull/145) rename grammar tests to core tests, since it testing dust.js core functionality, also has GH-133, fix the missing helper case (@vybs)
- [#146](https://github.com/linkedin/dustjs/pull/146) Remove the old grammartests file, since it renamed to coreTests now and guard against missing context head in section (@vybs)
- [#151](https://github.com/linkedin/dustjs/pull/151) add v1.1 files to the dist (@vybs)
- [#152](https://github.com/linkedin/dustjs/pull/152) Really undo 2760048: removing scalar block support (@jimmyhchan)
- [#156](https://github.com/linkedin/dustjs/pull/156) Cleanup the helpers from the dust repo, fix the make test (@vybs)
- [#154](https://github.com/linkedin/dustjs/pull/154) partials with parameters context was missing blocks (@jimmyhchan)
- [#157](https://github.com/linkedin/dustjs/pull/157) Add unit tests for the pull/154 (@vybs)
- [#158](https://github.com/linkedin/dustjs/pull/158) fix the bad merge (@vybs)
- [#159](https://github.com/linkedin/dustjs/pull/159) fix the description on the core tests for $idx and $len for scalar (@vybs)
- [#165](https://github.com/linkedin/dustjs/pull/165) improve description in unit tests (@vybs)
- [#168](https://github.com/linkedin/dustjs/pull/168) Minor README update (@sethmcl)
- [#183](https://github.com/linkedin/dustjs/pull/183) cover, uglify and jasmine move to dev dependencies. GH-183 (@jairodemorais)
- [#166](https://github.com/linkedin/dustjs/pull/166) Add template strip of white space to dust.compile (optional defaults to not strip) (@smfoote)
- [#188](https://github.com/linkedin/dustjs/pull/188) The whitespace grammar rule for partial was a little inconsistent with other tags. issue GH=187 fixed. (@jairodemorais)
- [#216](https://github.com/linkedin/dustjs/pull/216) add semicolons to dust compiler GH=215 (@jairodemorais)
- [#223](https://github.com/linkedin/dustjs/pull/223) Fix for Issue #222. Code change + new test added to verify proper behavior (@rragan)
- [#236](https://github.com/linkedin/dustjs/pull/236) eol added to buffer again. (@jairodemorais)
- [#241](https://github.com/linkedin/dustjs/pull/241) using dust.isArray in place of Array.isArray (@jairodemorais)
- [#243](https://github.com/linkedin/dustjs/pull/243) compiler variable name changed to dustCompiler (@jairodemorais)
- [#245](https://github.com/linkedin/dustjs/pull/245) Gh-208 - solve the incorrect error line reported in peg (@jairodemorais)
- [#249](https://github.com/linkedin/dustjs/pull/249) Remove debugger in dust-full-1.2.1.js (@sethkinast)
- [#253](https://github.com/linkedin/dustjs/pull/253) 2-3000% performance enhancement in IE7 (@jlkonsultab)
- [#263](https://github.com/linkedin/dustjs/pull/263) Add forward slash and unit tests for j filter (@prashn64)
- [#274](https://github.com/linkedin/dustjs/pull/274) GH-266 store rendered template in global (@vybs)

19
node_modules/dustjs-linkedin/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2010 Aleksander Williams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

64
node_modules/dustjs-linkedin/README.md generated vendored Normal file
View File

@ -0,0 +1,64 @@
Dust [![Build Status](https://secure.travis-ci.org/linkedin/dustjs.png)](http://travis-ci.org/linkedin/dustjs)
====
This is the LinkedIn fork of Dust.
## Getting Started
A quick tutorial for how to use Dust <https://github.com/linkedin/dustjs/wiki/Dust-Tutorial>
More info <http://linkedin.github.io/dustjs/> and <http://linkedin.github.io/dustjs/#installation>
## More
Read more here: <http://linkedin.github.com/dustjs/>.
For LinkedIn dust-helpers: <https://github.com/linkedin/dustjs-helpers>.
For LinkedIn secure-filters : <https://github.com/linkedin/dustjs-filters-secure>.
## Building Dust locally
### Grab a copy of the repo
```
cd some_project_directory
git clone https://github.com/linkedin/dustjs.git dustjs
cd dustjs
```
### (Optional) Install Grunt-cli
* Grunt-cli lets you run Grunt from within a subfolder see http://gruntjs.com/getting-started
```
npm install -g grunt-cli
```
### Fetch all the node dependencies
```
npm install
```
### Run tests
```
grunt test
```
## Contributing to Dust
* Setup a branch for what you are working on
git checkout -b myBranchName
* Test your changes (jshint, unit tests in node, rhino and phantom and make sure test coverage thresholds are met)
grunt test
* Use `grunt dev` while developing\debugging.
This task will start a server and serve Jasmine spec runner on http://localhost:3000/_SpecRunner.html.
This tasks uses unminified dust-full.js so it allows you to easily step through the code in a browser.
* Use `grunt testClient` to test production version of code (dust-full.min.js) in a browser.
Similarly to `grunt dev` it serves Jasmine spec runner on `http://localhost:3000/_SpecRunner.html`.
* Add unit tests
Unit tests can be found in the `test/jasmine-tests/spec` directory. Help us keep up good test coverage! To view coverage report run `grunt coverage` and open `tmp/coverage/index.html` in a browser.
* Add an issue and send a pull request
Pull requests are easier to track if you also include an issue. Sending a pull request from a branch makes it easier for you to resolve conflicts in master

70
node_modules/dustjs-linkedin/bin/dustc generated vendored Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env node
var path = require('path'),
fs = require('fs'),
sys = require('util'),
dust = require('../lib/server'),
args = process.argv.slice(1),
name = null;
args = args.filter(function (arg) {
var match;
if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=([^\s]+))?$/i)) { arg = match[1] }
else { return arg }
switch (arg) {
case 'h':
case 'help':
sys.puts("usage: dustc [{-n|--name}=<template_name>] {sourcefilename|-} [destination]");
process.exit(0);
case 'n':
case 'name':
name = match[2];
break;
}
});
var input = args[1];
var output = args[2];
if (output) {
output = path.resolve(process.cwd(), output);
}
var fd, template;
if (! input) {
sys.puts("dustc: no input files");
process.exit(1);
}
var parseDustFile = function (e, data) {
if (e) {
sys.puts("dustc: " + e.message);
process.exit(1);
}
template = dust.compile(data, name || input);
if (output) {
fd = fs.openSync(output, "w");
fs.writeSync(fd, template, 0, "utf8");
} else {
sys.print(template);
}
};
if (input != '-') {
fs.readFile(input, 'utf-8', parseDustFile);
} else {
process.stdin.resume();
process.stdin.setEncoding('utf8');
var buffer = '';
process.stdin.on('data', function(data) {
buffer += data;
});
process.stdin.on('end', function() {
parseDustFile(false, buffer);
});
}

24
node_modules/dustjs-linkedin/bower.json generated vendored Normal file
View File

@ -0,0 +1,24 @@
{
"name": "dustjs-linkedin",
"version": "2.4.2",
"main": "dist/dust-full.min.js",
"devDependencies": {
"pegjs": "0.8.0"
},
"ignore": [
"**/.*",
"tmp",
"docs",
"test",
"src",
"benchmark",
"archive",
"node_modules",
".grunt",
"_SpecRunner.html",
".travis.yml",
"Gruntfile.js",
"package.json",
"bower.json"
]
}

19
node_modules/dustjs-linkedin/dist/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2010 Aleksander Williams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

871
node_modules/dustjs-linkedin/dist/dust-core.js generated vendored Normal file
View File

@ -0,0 +1,871 @@
/*! Dust - Asynchronous Templating - v2.4.2
* http://linkedin.github.io/dustjs/
* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */
(function(root) {
var dust = {},
NONE = 'NONE',
ERROR = 'ERROR',
WARN = 'WARN',
INFO = 'INFO',
DEBUG = 'DEBUG',
loggingLevels = [DEBUG, INFO, WARN, ERROR, NONE],
EMPTY_FUNC = function() {},
logger = {},
originalLog,
loggerContext;
dust.debugLevel = NONE;
// Try to find the console in global scope
if (root && root.console && root.console.log) {
loggerContext = root.console;
originalLog = root.console.log;
}
// robust logger for node.js, modern browsers, and IE <= 9.
logger.log = loggerContext ? function() {
// Do this for normal browsers
if (typeof originalLog === 'function') {
logger.log = function() {
originalLog.apply(loggerContext, arguments);
};
} else {
// Do this for IE <= 9
logger.log = function() {
var message = Array.prototype.slice.apply(arguments).join(' ');
originalLog(message);
};
}
logger.log.apply(this, arguments);
} : function() { /* no op */ };
/**
* Log dust debug statements, info statements, warning statements, and errors.
* Filters out the messages based on the dust.debuglevel.
* This default implementation will print to the console if it exists.
* @param {String|Error} message the message to print/throw
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG)
* @public
*/
dust.log = function(message, type) {
type = type || INFO;
if (dust.debugLevel !== NONE && dust.indexInArray(loggingLevels, type) >= dust.indexInArray(loggingLevels, dust.debugLevel)) {
if(!dust.logQueue) {
dust.logQueue = [];
}
dust.logQueue.push({message: message, type: type});
logger.log('[DUST ' + type + ']: ' + message);
}
};
dust.helpers = {};
dust.cache = {};
dust.register = function(name, tmpl) {
if (!name) {
return;
}
dust.cache[name] = tmpl;
};
dust.render = function(name, context, callback) {
var chunk = new Stub(callback).head;
try {
dust.load(name, chunk, Context.wrap(context, name)).end();
} catch (err) {
chunk.setError(err);
}
};
dust.stream = function(name, context) {
var stream = new Stream(),
chunk = stream.head;
dust.nextTick(function() {
try {
dust.load(name, stream.head, Context.wrap(context, name)).end();
} catch (err) {
chunk.setError(err);
}
});
return stream;
};
dust.renderSource = function(source, context, callback) {
return dust.compileFn(source)(context, callback);
};
dust.compileFn = function(source, name) {
// name is optional. When name is not provided the template can only be rendered using the callable returned by this function.
// If a name is provided the compiled template can also be rendered by name.
name = name || null;
var tmpl = dust.loadSource(dust.compile(source, name));
return function(context, callback) {
var master = callback ? new Stub(callback) : new Stream();
dust.nextTick(function() {
if(typeof tmpl === 'function') {
tmpl(master.head, Context.wrap(context, name)).end();
}
else {
dust.log(new Error('Template [' + name + '] cannot be resolved to a Dust function'), ERROR);
}
});
return master;
};
};
dust.load = function(name, chunk, context) {
var tmpl = dust.cache[name];
if (tmpl) {
return tmpl(chunk, context);
} else {
if (dust.onLoad) {
return chunk.map(function(chunk) {
dust.onLoad(name, function(err, src) {
if (err) {
return chunk.setError(err);
}
if (!dust.cache[name]) {
dust.loadSource(dust.compile(src, name));
}
dust.cache[name](chunk, context).end();
});
});
}
return chunk.setError(new Error('Template Not Found: ' + name));
}
};
dust.loadSource = function(source, path) {
return eval(source);
};
if (Array.isArray) {
dust.isArray = Array.isArray;
} else {
dust.isArray = function(arr) {
return Object.prototype.toString.call(arr) === '[object Array]';
};
}
// indexOf shim for arrays for IE <= 8
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
dust.indexInArray = function(arr, item, fromIndex) {
fromIndex = +fromIndex || 0;
if (Array.prototype.indexOf) {
return arr.indexOf(item, fromIndex);
} else {
if ( arr === undefined || arr === null ) {
throw new TypeError( 'cannot call method "indexOf" of null' );
}
var length = arr.length; // Hack to convert object.length to a UInt32
if (Math.abs(fromIndex) === Infinity) {
fromIndex = 0;
}
if (fromIndex < 0) {
fromIndex += length;
if (fromIndex < 0) {
fromIndex = 0;
}
}
for (;fromIndex < length; fromIndex++) {
if (arr[fromIndex] === item) {
return fromIndex;
}
}
return -1;
}
};
dust.nextTick = (function() {
return function(callback) {
setTimeout(callback,0);
};
} )();
dust.isEmpty = function(value) {
if (dust.isArray(value) && !value.length) {
return true;
}
if (value === 0) {
return false;
}
return (!value);
};
// apply the filter chain and return the output string
dust.filter = function(string, auto, filters) {
if (filters) {
for (var i=0, len=filters.length; i<len; i++) {
var name = filters[i];
if (name === 's') {
auto = null;
}
else if (typeof dust.filters[name] === 'function') {
string = dust.filters[name](string);
}
else {
dust.log('Invalid filter [' + name + ']', WARN);
}
}
}
// by default always apply the h filter, unless asked to unescape with |s
if (auto) {
string = dust.filters[auto](string);
}
return string;
};
dust.filters = {
h: function(value) { return dust.escapeHtml(value); },
j: function(value) { return dust.escapeJs(value); },
u: encodeURI,
uc: encodeURIComponent,
js: function(value) {
if (!JSON) {
dust.log('JSON is undefined. JSON stringify has not been used on [' + value + ']', WARN);
return value;
} else {
return JSON.stringify(value);
}
},
jp: function(value) {
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN);
return value;
} else {
return JSON.parse(value);
}
}
};
function Context(stack, global, blocks, templateName) {
this.stack = stack;
this.global = global;
this.blocks = blocks;
this.templateName = templateName;
}
dust.makeBase = function(global) {
return new Context(new Stack(), global);
};
Context.wrap = function(context, name) {
if (context instanceof Context) {
return context;
}
return new Context(new Stack(context), {}, null, name);
};
/**
* Public API for getting a value from the context.
* @method get
* @param {string|array} path The path to the value. Supported formats are:
* 'key'
* 'path.to.key'
* '.path.to.key'
* ['path', 'to', 'key']
* ['key']
* @param {boolean} [cur=false] Boolean which determines if the search should be limited to the
* current context (true), or if get should search in parent contexts as well (false).
* @public
* @returns {string|object}
*/
Context.prototype.get = function(path, cur) {
if (typeof path === 'string') {
if (path[0] === '.') {
cur = true;
path = path.substr(1);
}
path = path.split('.');
}
return this._get(cur, path);
};
/**
* Get a value from the context
* @method _get
* @param {boolean} cur Get only from the current context
* @param {array} down An array of each step in the path
* @private
* @return {string | object}
*/
Context.prototype._get = function(cur, down) {
var ctx = this.stack,
i = 1,
value, first, len, ctxThis;
first = down[0];
len = down.length;
if (cur && len === 0) {
ctxThis = ctx;
ctx = ctx.head;
} else {
if (!cur) {
// Search up the stack for the first value
while (ctx) {
if (ctx.isObject) {
ctxThis = ctx.head;
value = ctx.head[first];
if (value !== undefined) {
break;
}
}
ctx = ctx.tail;
}
if (value !== undefined) {
ctx = value;
} else {
ctx = this.global ? this.global[first] : undefined;
}
} else if (ctx) {
// if scope is limited by a leading dot, don't search up the tree
if(ctx.head) {
ctx = ctx.head[first];
} else {
//context's head is empty, value we are searching for is not defined
ctx = undefined;
}
}
while (ctx && i < len) {
ctxThis = ctx;
ctx = ctx[down[i]];
i++;
}
}
// Return the ctx or a function wrapping the application of the context.
if (typeof ctx === 'function') {
return function() {
try {
return ctx.apply(ctxThis, arguments);
} catch (err) {
dust.log(err, ERROR);
throw err;
}
};
} else {
if (ctx === undefined) {
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']');
}
return ctx;
}
};
Context.prototype.getPath = function(cur, down) {
return this._get(cur, down);
};
Context.prototype.push = function(head, idx, len) {
return new Context(new Stack(head, this.stack, idx, len), this.global, this.blocks, this.getTemplateName());
};
Context.prototype.rebase = function(head) {
return new Context(new Stack(head), this.global, this.blocks, this.getTemplateName());
};
Context.prototype.current = function() {
return this.stack.head;
};
Context.prototype.getBlock = function(key, chk, ctx) {
if (typeof key === 'function') {
var tempChk = new Chunk();
key = key(tempChk, this).data.join('');
}
var blocks = this.blocks;
if (!blocks) {
dust.log('No blocks for context[{' + key + '}] in template [' + this.getTemplateName() + ']', DEBUG);
return;
}
var len = blocks.length, fn;
while (len--) {
fn = blocks[len][key];
if (fn) {
return fn;
}
}
};
Context.prototype.shiftBlocks = function(locals) {
var blocks = this.blocks,
newBlocks;
if (locals) {
if (!blocks) {
newBlocks = [locals];
} else {
newBlocks = blocks.concat([locals]);
}
return new Context(this.stack, this.global, newBlocks, this.getTemplateName());
}
return this;
};
Context.prototype.getTemplateName = function() {
return this.templateName;
};
function Stack(head, tail, idx, len) {
this.tail = tail;
this.isObject = head && typeof head === 'object';
this.head = head;
this.index = idx;
this.of = len;
}
function Stub(callback) {
this.head = new Chunk(this);
this.callback = callback;
this.out = '';
}
Stub.prototype.flush = function() {
var chunk = this.head;
while (chunk) {
if (chunk.flushable) {
this.out += chunk.data.join(''); //ie7 perf
} else if (chunk.error) {
this.callback(chunk.error);
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN);
this.flush = EMPTY_FUNC;
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.callback(null, this.out);
};
function Stream() {
this.head = new Chunk(this);
}
Stream.prototype.flush = function() {
var chunk = this.head;
while(chunk) {
if (chunk.flushable) {
this.emit('data', chunk.data.join('')); //ie7 perf
} else if (chunk.error) {
this.emit('error', chunk.error);
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN);
this.flush = EMPTY_FUNC;
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.emit('end');
};
Stream.prototype.emit = function(type, data) {
if (!this.events) {
dust.log('No events to emit', INFO);
return false;
}
var handler = this.events[type];
if (!handler) {
dust.log('Event type [' + type + '] does not exist', WARN);
return false;
}
if (typeof handler === 'function') {
handler(data);
} else if (dust.isArray(handler)) {
var listeners = handler.slice(0);
for (var i = 0, l = listeners.length; i < l; i++) {
listeners[i](data);
}
} else {
dust.log('Event Handler [' + handler + '] is not of a type that is handled by emit', WARN);
}
};
Stream.prototype.on = function(type, callback) {
if (!this.events) {
this.events = {};
}
if (!this.events[type]) {
dust.log('Event type [' + type + '] does not exist. Using just the specified callback.', WARN);
if(callback) {
this.events[type] = callback;
} else {
dust.log('Callback for type [' + type + '] does not exist. Listener not registered.', WARN);
}
} else if(typeof this.events[type] === 'function') {
this.events[type] = [this.events[type], callback];
} else {
this.events[type].push(callback);
}
return this;
};
Stream.prototype.pipe = function(stream) {
this.on('data', function(data) {
try {
stream.write(data, 'utf8');
} catch (err) {
dust.log(err, ERROR);
}
}).on('end', function() {
try {
return stream.end();
} catch (err) {
dust.log(err, ERROR);
}
}).on('error', function(err) {
stream.error(err);
});
return this;
};
function Chunk(root, next, taps) {
this.root = root;
this.next = next;
this.data = []; //ie7 perf
this.flushable = false;
this.taps = taps;
}
Chunk.prototype.write = function(data) {
var taps = this.taps;
if (taps) {
data = taps.go(data);
}
this.data.push(data);
return this;
};
Chunk.prototype.end = function(data) {
if (data) {
this.write(data);
}
this.flushable = true;
this.root.flush();
return this;
};
Chunk.prototype.map = function(callback) {
var cursor = new Chunk(this.root, this.next, this.taps),
branch = new Chunk(this.root, cursor, this.taps);
this.next = branch;
this.flushable = true;
try {
callback(branch);
} catch(e) {
dust.log(e, ERROR);
branch.setError(e);
}
return cursor;
};
Chunk.prototype.tap = function(tap) {
var taps = this.taps;
if (taps) {
this.taps = taps.push(tap);
} else {
this.taps = new Tap(tap);
}
return this;
};
Chunk.prototype.untap = function() {
this.taps = this.taps.tail;
return this;
};
Chunk.prototype.render = function(body, context) {
return body(this, context);
};
Chunk.prototype.reference = function(elem, context, auto, filters) {
if (typeof elem === 'function') {
// Changed the function calling to use apply with the current context to make sure
// that "this" is wat we expect it to be inside the function
elem = elem.apply(context.current(), [this, context, null, {auto: auto, filters: filters}]);
if (elem instanceof Chunk) {
return elem;
}
}
if (!dust.isEmpty(elem)) {
return this.write(dust.filter(elem, auto, filters));
} else {
return this;
}
};
Chunk.prototype.section = function(elem, context, bodies, params) {
// anonymous functions
if (typeof elem === 'function') {
try {
elem = elem.apply(context.current(), [this, context, bodies, params]);
} catch(e) {
dust.log(e, ERROR);
return this.setError(e);
}
// functions that return chunks are assumed to have handled the body and/or have modified the chunk
// use that return value as the current chunk and go to the next method in the chain
if (elem instanceof Chunk) {
return elem;
}
}
var body = bodies.block,
skip = bodies['else'];
// a.k.a Inline parameters in the Dust documentations
if (params) {
context = context.push(params);
}
/*
Dust's default behavior is to enumerate over the array elem, passing each object in the array to the block.
When elem resolves to a value or object instead of an array, Dust sets the current context to the value
and renders the block one time.
*/
//non empty array is truthy, empty array is falsy
if (dust.isArray(elem)) {
if (body) {
var len = elem.length, chunk = this;
if (len > 0) {
// any custom helper can blow up the stack
// and store a flattened context, guard defensively
if(context.stack.head) {
context.stack.head['$len'] = len;
}
for (var i=0; i<len; i++) {
if(context.stack.head) {
context.stack.head['$idx'] = i;
}
chunk = body(chunk, context.push(elem[i], i, len));
}
if(context.stack.head) {
context.stack.head['$idx'] = undefined;
context.stack.head['$len'] = undefined;
}
return chunk;
}
else if (skip) {
return skip(this, context);
}
}
} else if (elem === true) {
// true is truthy but does not change context
if (body) {
return body(this, context);
}
} else if (elem || elem === 0) {
// everything that evaluates to true are truthy ( e.g. Non-empty strings and Empty objects are truthy. )
// zero is truthy
// for anonymous functions that did not returns a chunk, truthiness is evaluated based on the return value
if (body) {
return body(this, context.push(elem));
}
// nonexistent, scalar false value, scalar empty string, null,
// undefined are all falsy
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering section (#) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG);
return this;
};
Chunk.prototype.exists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (!dust.isEmpty(elem)) {
if (body) {
return body(this, context);
}
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering exists (?) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG);
return this;
};
Chunk.prototype.notexists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (dust.isEmpty(elem)) {
if (body) {
return body(this, context);
}
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering not exists (^) block check in template [' + context.getTemplateName() + '], because above key was found', DEBUG);
return this;
};
Chunk.prototype.block = function(elem, context, bodies) {
var body = bodies.block;
if (elem) {
body = elem;
}
if (body) {
return body(this, context);
}
return this;
};
Chunk.prototype.partial = function(elem, context, params) {
var partialContext;
//put the params context second to match what section does. {.} matches the current context without parameters
// start with an empty context
partialContext = dust.makeBase(context.global);
partialContext.blocks = context.blocks;
if (context.stack && context.stack.tail){
// grab the stack(tail) off of the previous context if we have it
partialContext.stack = context.stack.tail;
}
if (params){
//put params on
partialContext = partialContext.push(params);
}
if(typeof elem === 'string') {
partialContext.templateName = elem;
}
//reattach the head
partialContext = partialContext.push(context.stack.head);
var partialChunk;
if (typeof elem === 'function') {
partialChunk = this.capture(elem, partialContext, function(name, chunk) {
partialContext.templateName = partialContext.templateName || name;
dust.load(name, chunk, partialContext).end();
});
} else {
partialChunk = dust.load(elem, this, partialContext);
}
return partialChunk;
};
Chunk.prototype.helper = function(name, context, bodies, params) {
var chunk = this;
// handle invalid helpers, similar to invalid filters
if(dust.helpers[name]) {
try {
return dust.helpers[name](chunk, context, bodies, params);
} catch(e) {
dust.log('Error in ' + name + ' helper: ' + e, ERROR);
return chunk.setError(e);
}
} else {
dust.log('Invalid helper [' + name + ']', WARN);
return chunk;
}
};
Chunk.prototype.capture = function(body, context, callback) {
return this.map(function(chunk) {
var stub = new Stub(function(err, out) {
if (err) {
chunk.setError(err);
} else {
callback(out, chunk);
}
});
body(stub.head, context).end();
});
};
Chunk.prototype.setError = function(err) {
this.error = err;
this.root.flush();
return this;
};
function Tap(head, tail) {
this.head = head;
this.tail = tail;
}
Tap.prototype.push = function(tap) {
return new Tap(tap, this);
};
Tap.prototype.go = function(value) {
var tap = this;
while(tap) {
value = tap.head(value);
tap = tap.tail;
}
return value;
};
var HCHARS = new RegExp(/[&<>\"\']/),
AMP = /&/g,
LT = /</g,
GT = />/g,
QUOT = /\"/g,
SQUOT = /\'/g;
dust.escapeHtml = function(s) {
if (typeof s === 'string') {
if (!HCHARS.test(s)) {
return s;
}
return s.replace(AMP,'&amp;').replace(LT,'&lt;').replace(GT,'&gt;').replace(QUOT,'&quot;').replace(SQUOT, '&#39;');
}
return s;
};
var BS = /\\/g,
FS = /\//g,
CR = /\r/g,
LS = /\u2028/g,
PS = /\u2029/g,
NL = /\n/g,
LF = /\f/g,
SQ = /'/g,
DQ = /"/g,
TB = /\t/g;
dust.escapeJs = function(s) {
if (typeof s === 'string') {
return s
.replace(BS, '\\\\')
.replace(FS, '\\/')
.replace(DQ, '\\"')
.replace(SQ, '\\\'')
.replace(CR, '\\r')
.replace(LS, '\\u2028')
.replace(PS, '\\u2029')
.replace(NL, '\\n')
.replace(LF, '\\f')
.replace(TB, '\\t');
}
return s;
};
if (typeof exports === 'object') {
module.exports = dust;
} else {
root.dust = dust;
}
})((function(){return this;})());

4
node_modules/dustjs-linkedin/dist/dust-core.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

3953
node_modules/dustjs-linkedin/dist/dust-full.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

5
node_modules/dustjs-linkedin/dist/dust-full.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

39
node_modules/dustjs-linkedin/lib/README.md generated vendored Normal file
View File

@ -0,0 +1,39 @@
## What's all this here
### Dust in parts
The Dust project consists of 3 parts:
* **dust.js** - the core (runtime) file responsible for providing:
* a `dust` namespace
* all public end user API methods (such as `dust.render`, `dust.makebase`)
* all publically overridable methods (such as `dust.onError`, `dust.log`) and overridable objects (`dust.helper`)
* shared utility methods used internally (such as `dust.isArray`)
* definitions for all internal objects (such as `Context`, `Stub`, `Stream`, etc.)
* ... which include all internal methods called from the templates (such as `context.get`, `chunk.section`, `chunk.partial`, etc.)
* **parser.js** - responsible for providing a parse methods which things that look like Dust and turning it into a Dust AST
* **compiler.js** - responsible for taking Dust AST and turning it into Javscript functions that can be `dust.render`'ed
### server.js
There is one more file in lib: **server.js** (see package.json). This file is the entry point for Node environments.
### dust-core pre-compiling files and keeping a slim runtime
For browser performance, we recommend providing only the **dust-core.js** file to the browser and compiling templates on the server.
You can think of **dust-core.js** as the runtime file. Currently, core only include **dust.js** which provides enough to render basic templates in the browser(without helpers; for templates with helpers see the dustjs-helpers repo).
### dust-full when you need to compile
When you need to compile templates, that is take files written in Dust syntax and converting them to things that can be `dust.render`'ed, you'll need **dust-full.js**. The **compiler.js** and **parser.js** file are included with **dust.js** in **dust-full.js** in order to provide the compile functionality.
You should provide **dust-full.js** to the browser if you are compiling templates on demand or if simply just don't want to pre-compile on the server and perf does not matter.
If you are using Node and using `require('dustjs-linkedin')` you are getting dust-full.
### Server vs Browser - the server file
Dust is written to run on both the server and the browser. In truth, it is written to work first on the browser and modified to work on the server.
A few things are added to make it work on the server:
* A UMD style wrapper is added to all the files so that, for example, `dust` is returned to `module.exports` in Node whereas it would have returned as `window.dust` in the browser
* Servers that use npm (Node) need a single main entry point. For us, this is **server.js** which sets up `dust-full` by pulling in the necessary lib modules, modifies some methods to work in Node, and exports it as a module.
* Browsers don't need to be a single file but to make it easier a build script is setup so that the necessary lib files are combined into **dist/dust-full.js** and **dist/dust-core.js**.

418
node_modules/dustjs-linkedin/lib/compiler.js generated vendored Normal file
View File

@ -0,0 +1,418 @@
/*jshint latedef:false */
(function(root, factory) {
if (typeof exports === 'object') {
// in Node, require this file if we want to use the compiler as a standalone module
module.exports = factory(require('./parser').parse, require('./dust'));
} else {
// in the browser, store the factory output if we want to use the compiler directly
factory(root.dust.parse, root.dust);
}
}(this, function(parse, dust) {
var compiler = {},
isArray = dust.isArray;
compiler.compile = function(source, name) {
// the name parameter is optional.
// this can happen for templates that are rendered immediately (renderSource which calls compileFn) or
// for templates that are compiled as a callable (compileFn)
//
// for the common case (using compile and render) a name is required so that templates will be cached by name and rendered later, by name.
if (!name && name !== null) {
throw new Error('Template name parameter cannot be undefined when calling dust.compile');
}
try {
var ast = filterAST(parse(source));
return compile(ast, name);
}
catch (err)
{
if (!err.line || !err.column) {
throw err;
}
throw new SyntaxError(err.message + ' At line : ' + err.line + ', column : ' + err.column);
}
};
function filterAST(ast) {
var context = {};
return compiler.filterNode(context, ast);
}
compiler.filterNode = function(context, node) {
return compiler.optimizers[node[0]](context, node);
};
compiler.optimizers = {
body: compactBuffers,
buffer: noop,
special: convertSpecial,
format: nullify, // TODO: convert format
reference: visit,
'#': visit,
'?': visit,
'^': visit,
'<': visit,
'+': visit,
'@': visit,
'%': visit,
partial: visit,
context: visit,
params: visit,
bodies: visit,
param: visit,
filters: noop,
key: noop,
path: noop,
literal: noop,
raw: noop,
comment: nullify,
line: nullify,
col: nullify
};
compiler.pragmas = {
esc: function(compiler, context, bodies, params) {
var old = compiler.auto,
out;
if (!context) {
context = 'h';
}
compiler.auto = (context === 's') ? '' : context;
out = compileParts(compiler, bodies.block);
compiler.auto = old;
return out;
}
};
function visit(context, node) {
var out = [node[0]],
i, len, res;
for (i=1, len=node.length; i<len; i++) {
res = compiler.filterNode(context, node[i]);
if (res) {
out.push(res);
}
}
return out;
}
// Compacts consecutive buffer nodes into a single node
function compactBuffers(context, node) {
var out = [node[0]],
memo, i, len, res;
for (i=1, len=node.length; i<len; i++) {
res = compiler.filterNode(context, node[i]);
if (res) {
if (res[0] === 'buffer') {
if (memo) {
memo[1] += res[1];
} else {
memo = res;
out.push(res);
}
} else {
memo = null;
out.push(res);
}
}
}
return out;
}
var specialChars = {
's': ' ',
'n': '\n',
'r': '\r',
'lb': '{',
'rb': '}'
};
function convertSpecial(context, node) {
return ['buffer', specialChars[node[1]]];
}
function noop(context, node) {
return node;
}
function nullify(){}
function compile(ast, name) {
var context = {
name: name,
bodies: [],
blocks: {},
index: 0,
auto: 'h'
};
return '(function(){dust.register(' +
(name ? '"' + name + '"' : 'null') + ',' +
compiler.compileNode(context, ast) +
');' +
compileBlocks(context) +
compileBodies(context) +
'return body_0;' +
'})();';
}
function compileBlocks(context) {
var out = [],
blocks = context.blocks,
name;
for (name in blocks) {
out.push('"' + name + '":' + blocks[name]);
}
if (out.length) {
context.blocks = 'ctx=ctx.shiftBlocks(blocks);';
return 'var blocks={' + out.join(',') + '};';
}
return context.blocks = '';
}
function compileBodies(context) {
var out = [],
bodies = context.bodies,
blx = context.blocks,
i, len;
for (i=0, len=bodies.length; i<len; i++) {
out[i] = 'function body_' + i + '(chk,ctx){' +
blx + 'return chk' + bodies[i] + ';}';
}
return out.join('');
}
function compileParts(context, body) {
var parts = '',
i, len;
for (i=1, len=body.length; i<len; i++) {
parts += compiler.compileNode(context, body[i]);
}
return parts;
}
compiler.compileNode = function(context, node) {
return compiler.nodes[node[0]](context, node);
};
compiler.nodes = {
body: function(context, node) {
var id = context.index++,
name = 'body_' + id;
context.bodies[id] = compileParts(context, node);
return name;
},
buffer: function(context, node) {
return '.write(' + escape(node[1]) + ')';
},
format: function(context, node) {
return '.write(' + escape(node[1] + node[2]) + ')';
},
reference: function(context, node) {
return '.reference(' + compiler.compileNode(context, node[1]) +
',ctx,' + compiler.compileNode(context, node[2]) + ')';
},
'#': function(context, node) {
return compileSection(context, node, 'section');
},
'?': function(context, node) {
return compileSection(context, node, 'exists');
},
'^': function(context, node) {
return compileSection(context, node, 'notexists');
},
'<': function(context, node) {
var bodies = node[4];
for (var i=1, len=bodies.length; i<len; i++) {
var param = bodies[i],
type = param[1][1];
if (type === 'block') {
context.blocks[node[1].text] = compiler.compileNode(context, param[2]);
return '';
}
}
return '';
},
'+': function(context, node) {
if (typeof(node[1].text) === 'undefined' && typeof(node[4]) === 'undefined'){
return '.block(ctx.getBlock(' +
compiler.compileNode(context, node[1]) +
',chk, ctx),' + compiler.compileNode(context, node[2]) + ', {},' +
compiler.compileNode(context, node[3]) +
')';
} else {
return '.block(ctx.getBlock(' +
escape(node[1].text) +
'),' + compiler.compileNode(context, node[2]) + ',' +
compiler.compileNode(context, node[4]) + ',' +
compiler.compileNode(context, node[3]) +
')';
}
},
'@': function(context, node) {
return '.helper(' +
escape(node[1].text) +
',' + compiler.compileNode(context, node[2]) + ',' +
compiler.compileNode(context, node[4]) + ',' +
compiler.compileNode(context, node[3]) +
')';
},
'%': function(context, node) {
// TODO: Move these hacks into pragma precompiler
var name = node[1][1],
rawBodies,
bodies,
rawParams,
params,
ctx, b, p, i, len;
if (!compiler.pragmas[name]) {
return '';
}
rawBodies = node[4];
bodies = {};
for (i=1, len=rawBodies.length; i<len; i++) {
b = rawBodies[i];
bodies[b[1][1]] = b[2];
}
rawParams = node[3];
params = {};
for (i=1, len=rawParams.length; i<len; i++) {
p = rawParams[i];
params[p[1][1]] = p[2][1];
}
ctx = node[2][1] ? node[2][1].text : null;
return compiler.pragmas[name](context, ctx, bodies, params);
},
partial: function(context, node) {
return '.partial(' +
compiler.compileNode(context, node[1]) +
',' + compiler.compileNode(context, node[2]) +
',' + compiler.compileNode(context, node[3]) + ')';
},
context: function(context, node) {
if (node[1]) {
return 'ctx.rebase(' + compiler.compileNode(context, node[1]) + ')';
}
return 'ctx';
},
params: function(context, node) {
var out = [];
for (var i=1, len=node.length; i<len; i++) {
out.push(compiler.compileNode(context, node[i]));
}
if (out.length) {
return '{' + out.join(',') + '}';
}
return '{}';
},
bodies: function(context, node) {
var out = [];
for (var i=1, len=node.length; i<len; i++) {
out.push(compiler.compileNode(context, node[i]));
}
return '{' + out.join(',') + '}';
},
param: function(context, node) {
return compiler.compileNode(context, node[1]) + ':' + compiler.compileNode(context, node[2]);
},
filters: function(context, node) {
var list = [];
for (var i=1, len=node.length; i<len; i++) {
var filter = node[i];
list.push('"' + filter + '"');
}
return '"' + context.auto + '"' +
(list.length ? ',[' + list.join(',') + ']' : '');
},
key: function(context, node) {
return 'ctx.get(["' + node[1] + '"], false)';
},
path: function(context, node) {
var current = node[1],
keys = node[2],
list = [];
for (var i=0,len=keys.length; i<len; i++) {
if (isArray(keys[i])) {
list.push(compiler.compileNode(context, keys[i]));
} else {
list.push('"' + keys[i] + '"');
}
}
return 'ctx.getPath(' + current + ', [' + list.join(',') + '])';
},
literal: function(context, node) {
return escape(node[1]);
},
raw: function(context, node) {
return ".write(" + escape(node[1]) + ")";
}
};
function compileSection(context, node, cmd) {
return '.' + cmd + '(' +
compiler.compileNode(context, node[1]) +
',' + compiler.compileNode(context, node[2]) + ',' +
compiler.compileNode(context, node[4]) + ',' +
compiler.compileNode(context, node[3]) +
')';
}
var BS = /\\/g,
DQ = /"/g,
LF = /\f/g,
NL = /\n/g,
CR = /\r/g,
TB = /\t/g;
function escapeToJsSafeString(str) {
return str.replace(BS, '\\\\')
.replace(DQ, '\\"')
.replace(LF, '\\f')
.replace(NL, '\\n')
.replace(CR, '\\r')
.replace(TB, '\\t');
}
var escape = (typeof JSON === 'undefined') ?
function(str) { return '"' + escapeToJsSafeString(str) + '"';} :
JSON.stringify;
// expose compiler methods
dust.compile = compiler.compile;
dust.filterNode = compiler.filterNode;
dust.optimizers = compiler.optimizers;
dust.pragmas = compiler.pragmas;
dust.compileNode = compiler.compileNode;
dust.nodes = compiler.nodes;
return compiler;
}));

869
node_modules/dustjs-linkedin/lib/dust.js generated vendored Normal file
View File

@ -0,0 +1,869 @@
/*jshint evil:true*/
(function(root) {
var dust = {},
NONE = 'NONE',
ERROR = 'ERROR',
WARN = 'WARN',
INFO = 'INFO',
DEBUG = 'DEBUG',
loggingLevels = [DEBUG, INFO, WARN, ERROR, NONE],
EMPTY_FUNC = function() {},
logger = {},
originalLog,
loggerContext;
dust.debugLevel = NONE;
// Try to find the console in global scope
if (root && root.console && root.console.log) {
loggerContext = root.console;
originalLog = root.console.log;
}
// robust logger for node.js, modern browsers, and IE <= 9.
logger.log = loggerContext ? function() {
// Do this for normal browsers
if (typeof originalLog === 'function') {
logger.log = function() {
originalLog.apply(loggerContext, arguments);
};
} else {
// Do this for IE <= 9
logger.log = function() {
var message = Array.prototype.slice.apply(arguments).join(' ');
originalLog(message);
};
}
logger.log.apply(this, arguments);
} : function() { /* no op */ };
/**
* Log dust debug statements, info statements, warning statements, and errors.
* Filters out the messages based on the dust.debuglevel.
* This default implementation will print to the console if it exists.
* @param {String|Error} message the message to print/throw
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG)
* @public
*/
dust.log = function(message, type) {
type = type || INFO;
if (dust.debugLevel !== NONE && dust.indexInArray(loggingLevels, type) >= dust.indexInArray(loggingLevels, dust.debugLevel)) {
if(!dust.logQueue) {
dust.logQueue = [];
}
dust.logQueue.push({message: message, type: type});
logger.log('[DUST ' + type + ']: ' + message);
}
};
dust.helpers = {};
dust.cache = {};
dust.register = function(name, tmpl) {
if (!name) {
return;
}
dust.cache[name] = tmpl;
};
dust.render = function(name, context, callback) {
var chunk = new Stub(callback).head;
try {
dust.load(name, chunk, Context.wrap(context, name)).end();
} catch (err) {
chunk.setError(err);
}
};
dust.stream = function(name, context) {
var stream = new Stream(),
chunk = stream.head;
dust.nextTick(function() {
try {
dust.load(name, stream.head, Context.wrap(context, name)).end();
} catch (err) {
chunk.setError(err);
}
});
return stream;
};
dust.renderSource = function(source, context, callback) {
return dust.compileFn(source)(context, callback);
};
dust.compileFn = function(source, name) {
// name is optional. When name is not provided the template can only be rendered using the callable returned by this function.
// If a name is provided the compiled template can also be rendered by name.
name = name || null;
var tmpl = dust.loadSource(dust.compile(source, name));
return function(context, callback) {
var master = callback ? new Stub(callback) : new Stream();
dust.nextTick(function() {
if(typeof tmpl === 'function') {
tmpl(master.head, Context.wrap(context, name)).end();
}
else {
dust.log(new Error('Template [' + name + '] cannot be resolved to a Dust function'), ERROR);
}
});
return master;
};
};
dust.load = function(name, chunk, context) {
var tmpl = dust.cache[name];
if (tmpl) {
return tmpl(chunk, context);
} else {
if (dust.onLoad) {
return chunk.map(function(chunk) {
dust.onLoad(name, function(err, src) {
if (err) {
return chunk.setError(err);
}
if (!dust.cache[name]) {
dust.loadSource(dust.compile(src, name));
}
dust.cache[name](chunk, context).end();
});
});
}
return chunk.setError(new Error('Template Not Found: ' + name));
}
};
dust.loadSource = function(source, path) {
return eval(source);
};
if (Array.isArray) {
dust.isArray = Array.isArray;
} else {
dust.isArray = function(arr) {
return Object.prototype.toString.call(arr) === '[object Array]';
};
}
// indexOf shim for arrays for IE <= 8
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
dust.indexInArray = function(arr, item, fromIndex) {
fromIndex = +fromIndex || 0;
if (Array.prototype.indexOf) {
return arr.indexOf(item, fromIndex);
} else {
if ( arr === undefined || arr === null ) {
throw new TypeError( 'cannot call method "indexOf" of null' );
}
var length = arr.length; // Hack to convert object.length to a UInt32
if (Math.abs(fromIndex) === Infinity) {
fromIndex = 0;
}
if (fromIndex < 0) {
fromIndex += length;
if (fromIndex < 0) {
fromIndex = 0;
}
}
for (;fromIndex < length; fromIndex++) {
if (arr[fromIndex] === item) {
return fromIndex;
}
}
return -1;
}
};
dust.nextTick = (function() {
return function(callback) {
setTimeout(callback,0);
};
} )();
dust.isEmpty = function(value) {
if (dust.isArray(value) && !value.length) {
return true;
}
if (value === 0) {
return false;
}
return (!value);
};
// apply the filter chain and return the output string
dust.filter = function(string, auto, filters) {
if (filters) {
for (var i=0, len=filters.length; i<len; i++) {
var name = filters[i];
if (name === 's') {
auto = null;
}
else if (typeof dust.filters[name] === 'function') {
string = dust.filters[name](string);
}
else {
dust.log('Invalid filter [' + name + ']', WARN);
}
}
}
// by default always apply the h filter, unless asked to unescape with |s
if (auto) {
string = dust.filters[auto](string);
}
return string;
};
dust.filters = {
h: function(value) { return dust.escapeHtml(value); },
j: function(value) { return dust.escapeJs(value); },
u: encodeURI,
uc: encodeURIComponent,
js: function(value) {
if (!JSON) {
dust.log('JSON is undefined. JSON stringify has not been used on [' + value + ']', WARN);
return value;
} else {
return JSON.stringify(value);
}
},
jp: function(value) {
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN);
return value;
} else {
return JSON.parse(value);
}
}
};
function Context(stack, global, blocks, templateName) {
this.stack = stack;
this.global = global;
this.blocks = blocks;
this.templateName = templateName;
}
dust.makeBase = function(global) {
return new Context(new Stack(), global);
};
Context.wrap = function(context, name) {
if (context instanceof Context) {
return context;
}
return new Context(new Stack(context), {}, null, name);
};
/**
* Public API for getting a value from the context.
* @method get
* @param {string|array} path The path to the value. Supported formats are:
* 'key'
* 'path.to.key'
* '.path.to.key'
* ['path', 'to', 'key']
* ['key']
* @param {boolean} [cur=false] Boolean which determines if the search should be limited to the
* current context (true), or if get should search in parent contexts as well (false).
* @public
* @returns {string|object}
*/
Context.prototype.get = function(path, cur) {
if (typeof path === 'string') {
if (path[0] === '.') {
cur = true;
path = path.substr(1);
}
path = path.split('.');
}
return this._get(cur, path);
};
/**
* Get a value from the context
* @method _get
* @param {boolean} cur Get only from the current context
* @param {array} down An array of each step in the path
* @private
* @return {string | object}
*/
Context.prototype._get = function(cur, down) {
var ctx = this.stack,
i = 1,
value, first, len, ctxThis;
first = down[0];
len = down.length;
if (cur && len === 0) {
ctxThis = ctx;
ctx = ctx.head;
} else {
if (!cur) {
// Search up the stack for the first value
while (ctx) {
if (ctx.isObject) {
ctxThis = ctx.head;
value = ctx.head[first];
if (value !== undefined) {
break;
}
}
ctx = ctx.tail;
}
if (value !== undefined) {
ctx = value;
} else {
ctx = this.global ? this.global[first] : undefined;
}
} else if (ctx) {
// if scope is limited by a leading dot, don't search up the tree
if(ctx.head) {
ctx = ctx.head[first];
} else {
//context's head is empty, value we are searching for is not defined
ctx = undefined;
}
}
while (ctx && i < len) {
ctxThis = ctx;
ctx = ctx[down[i]];
i++;
}
}
// Return the ctx or a function wrapping the application of the context.
if (typeof ctx === 'function') {
return function() {
try {
return ctx.apply(ctxThis, arguments);
} catch (err) {
dust.log(err, ERROR);
throw err;
}
};
} else {
if (ctx === undefined) {
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']');
}
return ctx;
}
};
Context.prototype.getPath = function(cur, down) {
return this._get(cur, down);
};
Context.prototype.push = function(head, idx, len) {
return new Context(new Stack(head, this.stack, idx, len), this.global, this.blocks, this.getTemplateName());
};
Context.prototype.rebase = function(head) {
return new Context(new Stack(head), this.global, this.blocks, this.getTemplateName());
};
Context.prototype.current = function() {
return this.stack.head;
};
Context.prototype.getBlock = function(key, chk, ctx) {
if (typeof key === 'function') {
var tempChk = new Chunk();
key = key(tempChk, this).data.join('');
}
var blocks = this.blocks;
if (!blocks) {
dust.log('No blocks for context[{' + key + '}] in template [' + this.getTemplateName() + ']', DEBUG);
return;
}
var len = blocks.length, fn;
while (len--) {
fn = blocks[len][key];
if (fn) {
return fn;
}
}
};
Context.prototype.shiftBlocks = function(locals) {
var blocks = this.blocks,
newBlocks;
if (locals) {
if (!blocks) {
newBlocks = [locals];
} else {
newBlocks = blocks.concat([locals]);
}
return new Context(this.stack, this.global, newBlocks, this.getTemplateName());
}
return this;
};
Context.prototype.getTemplateName = function() {
return this.templateName;
};
function Stack(head, tail, idx, len) {
this.tail = tail;
this.isObject = head && typeof head === 'object';
this.head = head;
this.index = idx;
this.of = len;
}
function Stub(callback) {
this.head = new Chunk(this);
this.callback = callback;
this.out = '';
}
Stub.prototype.flush = function() {
var chunk = this.head;
while (chunk) {
if (chunk.flushable) {
this.out += chunk.data.join(''); //ie7 perf
} else if (chunk.error) {
this.callback(chunk.error);
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN);
this.flush = EMPTY_FUNC;
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.callback(null, this.out);
};
function Stream() {
this.head = new Chunk(this);
}
Stream.prototype.flush = function() {
var chunk = this.head;
while(chunk) {
if (chunk.flushable) {
this.emit('data', chunk.data.join('')); //ie7 perf
} else if (chunk.error) {
this.emit('error', chunk.error);
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN);
this.flush = EMPTY_FUNC;
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.emit('end');
};
Stream.prototype.emit = function(type, data) {
if (!this.events) {
dust.log('No events to emit', INFO);
return false;
}
var handler = this.events[type];
if (!handler) {
dust.log('Event type [' + type + '] does not exist', WARN);
return false;
}
if (typeof handler === 'function') {
handler(data);
} else if (dust.isArray(handler)) {
var listeners = handler.slice(0);
for (var i = 0, l = listeners.length; i < l; i++) {
listeners[i](data);
}
} else {
dust.log('Event Handler [' + handler + '] is not of a type that is handled by emit', WARN);
}
};
Stream.prototype.on = function(type, callback) {
if (!this.events) {
this.events = {};
}
if (!this.events[type]) {
dust.log('Event type [' + type + '] does not exist. Using just the specified callback.', WARN);
if(callback) {
this.events[type] = callback;
} else {
dust.log('Callback for type [' + type + '] does not exist. Listener not registered.', WARN);
}
} else if(typeof this.events[type] === 'function') {
this.events[type] = [this.events[type], callback];
} else {
this.events[type].push(callback);
}
return this;
};
Stream.prototype.pipe = function(stream) {
this.on('data', function(data) {
try {
stream.write(data, 'utf8');
} catch (err) {
dust.log(err, ERROR);
}
}).on('end', function() {
try {
return stream.end();
} catch (err) {
dust.log(err, ERROR);
}
}).on('error', function(err) {
stream.error(err);
});
return this;
};
function Chunk(root, next, taps) {
this.root = root;
this.next = next;
this.data = []; //ie7 perf
this.flushable = false;
this.taps = taps;
}
Chunk.prototype.write = function(data) {
var taps = this.taps;
if (taps) {
data = taps.go(data);
}
this.data.push(data);
return this;
};
Chunk.prototype.end = function(data) {
if (data) {
this.write(data);
}
this.flushable = true;
this.root.flush();
return this;
};
Chunk.prototype.map = function(callback) {
var cursor = new Chunk(this.root, this.next, this.taps),
branch = new Chunk(this.root, cursor, this.taps);
this.next = branch;
this.flushable = true;
try {
callback(branch);
} catch(e) {
dust.log(e, ERROR);
branch.setError(e);
}
return cursor;
};
Chunk.prototype.tap = function(tap) {
var taps = this.taps;
if (taps) {
this.taps = taps.push(tap);
} else {
this.taps = new Tap(tap);
}
return this;
};
Chunk.prototype.untap = function() {
this.taps = this.taps.tail;
return this;
};
Chunk.prototype.render = function(body, context) {
return body(this, context);
};
Chunk.prototype.reference = function(elem, context, auto, filters) {
if (typeof elem === 'function') {
// Changed the function calling to use apply with the current context to make sure
// that "this" is wat we expect it to be inside the function
elem = elem.apply(context.current(), [this, context, null, {auto: auto, filters: filters}]);
if (elem instanceof Chunk) {
return elem;
}
}
if (!dust.isEmpty(elem)) {
return this.write(dust.filter(elem, auto, filters));
} else {
return this;
}
};
Chunk.prototype.section = function(elem, context, bodies, params) {
// anonymous functions
if (typeof elem === 'function') {
try {
elem = elem.apply(context.current(), [this, context, bodies, params]);
} catch(e) {
dust.log(e, ERROR);
return this.setError(e);
}
// functions that return chunks are assumed to have handled the body and/or have modified the chunk
// use that return value as the current chunk and go to the next method in the chain
if (elem instanceof Chunk) {
return elem;
}
}
var body = bodies.block,
skip = bodies['else'];
// a.k.a Inline parameters in the Dust documentations
if (params) {
context = context.push(params);
}
/*
Dust's default behavior is to enumerate over the array elem, passing each object in the array to the block.
When elem resolves to a value or object instead of an array, Dust sets the current context to the value
and renders the block one time.
*/
//non empty array is truthy, empty array is falsy
if (dust.isArray(elem)) {
if (body) {
var len = elem.length, chunk = this;
if (len > 0) {
// any custom helper can blow up the stack
// and store a flattened context, guard defensively
if(context.stack.head) {
context.stack.head['$len'] = len;
}
for (var i=0; i<len; i++) {
if(context.stack.head) {
context.stack.head['$idx'] = i;
}
chunk = body(chunk, context.push(elem[i], i, len));
}
if(context.stack.head) {
context.stack.head['$idx'] = undefined;
context.stack.head['$len'] = undefined;
}
return chunk;
}
else if (skip) {
return skip(this, context);
}
}
} else if (elem === true) {
// true is truthy but does not change context
if (body) {
return body(this, context);
}
} else if (elem || elem === 0) {
// everything that evaluates to true are truthy ( e.g. Non-empty strings and Empty objects are truthy. )
// zero is truthy
// for anonymous functions that did not returns a chunk, truthiness is evaluated based on the return value
if (body) {
return body(this, context.push(elem));
}
// nonexistent, scalar false value, scalar empty string, null,
// undefined are all falsy
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering section (#) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG);
return this;
};
Chunk.prototype.exists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (!dust.isEmpty(elem)) {
if (body) {
return body(this, context);
}
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering exists (?) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG);
return this;
};
Chunk.prototype.notexists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (dust.isEmpty(elem)) {
if (body) {
return body(this, context);
}
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering not exists (^) block check in template [' + context.getTemplateName() + '], because above key was found', DEBUG);
return this;
};
Chunk.prototype.block = function(elem, context, bodies) {
var body = bodies.block;
if (elem) {
body = elem;
}
if (body) {
return body(this, context);
}
return this;
};
Chunk.prototype.partial = function(elem, context, params) {
var partialContext;
//put the params context second to match what section does. {.} matches the current context without parameters
// start with an empty context
partialContext = dust.makeBase(context.global);
partialContext.blocks = context.blocks;
if (context.stack && context.stack.tail){
// grab the stack(tail) off of the previous context if we have it
partialContext.stack = context.stack.tail;
}
if (params){
//put params on
partialContext = partialContext.push(params);
}
if(typeof elem === 'string') {
partialContext.templateName = elem;
}
//reattach the head
partialContext = partialContext.push(context.stack.head);
var partialChunk;
if (typeof elem === 'function') {
partialChunk = this.capture(elem, partialContext, function(name, chunk) {
partialContext.templateName = partialContext.templateName || name;
dust.load(name, chunk, partialContext).end();
});
} else {
partialChunk = dust.load(elem, this, partialContext);
}
return partialChunk;
};
Chunk.prototype.helper = function(name, context, bodies, params) {
var chunk = this;
// handle invalid helpers, similar to invalid filters
if(dust.helpers[name]) {
try {
return dust.helpers[name](chunk, context, bodies, params);
} catch(e) {
dust.log('Error in ' + name + ' helper: ' + e, ERROR);
return chunk.setError(e);
}
} else {
dust.log('Invalid helper [' + name + ']', WARN);
return chunk;
}
};
Chunk.prototype.capture = function(body, context, callback) {
return this.map(function(chunk) {
var stub = new Stub(function(err, out) {
if (err) {
chunk.setError(err);
} else {
callback(out, chunk);
}
});
body(stub.head, context).end();
});
};
Chunk.prototype.setError = function(err) {
this.error = err;
this.root.flush();
return this;
};
function Tap(head, tail) {
this.head = head;
this.tail = tail;
}
Tap.prototype.push = function(tap) {
return new Tap(tap, this);
};
Tap.prototype.go = function(value) {
var tap = this;
while(tap) {
value = tap.head(value);
tap = tap.tail;
}
return value;
};
var HCHARS = new RegExp(/[&<>\"\']/),
AMP = /&/g,
LT = /</g,
GT = />/g,
QUOT = /\"/g,
SQUOT = /\'/g;
dust.escapeHtml = function(s) {
if (typeof s === 'string') {
if (!HCHARS.test(s)) {
return s;
}
return s.replace(AMP,'&amp;').replace(LT,'&lt;').replace(GT,'&gt;').replace(QUOT,'&quot;').replace(SQUOT, '&#39;');
}
return s;
};
var BS = /\\/g,
FS = /\//g,
CR = /\r/g,
LS = /\u2028/g,
PS = /\u2029/g,
NL = /\n/g,
LF = /\f/g,
SQ = /'/g,
DQ = /"/g,
TB = /\t/g;
dust.escapeJs = function(s) {
if (typeof s === 'string') {
return s
.replace(BS, '\\\\')
.replace(FS, '\\/')
.replace(DQ, '\\"')
.replace(SQ, '\\\'')
.replace(CR, '\\r')
.replace(LS, '\\u2028')
.replace(PS, '\\u2029')
.replace(NL, '\\n')
.replace(LF, '\\f')
.replace(TB, '\\t');
}
return s;
};
if (typeof exports === 'object') {
module.exports = dust;
} else {
root.dust = dust;
}
})((function(){return this;})());

2664
node_modules/dustjs-linkedin/lib/parser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

17
node_modules/dustjs-linkedin/lib/server.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/*global process*/
var path = require('path'),
vm = require('vm'),
dust = require('./dust'),
parser = require('./parser'),
compiler = require('./compiler');
// use Node equivalents for some Dust methods
var context = vm.createContext({dust: dust});
dust.loadSource = function(source, path) {
return vm.runInContext(source, context, path);
};
dust.nextTick = process.nextTick;
module.exports = dust;

105
node_modules/dustjs-linkedin/package.json generated vendored Normal file
View File

@ -0,0 +1,105 @@
{
"name": "dustjs-linkedin",
"title": "Dust - Asynchronous Templating",
"version": "2.4.2",
"author": {
"name": "Aleksander Williams",
"url": "http://akdubya.github.com/dustjs"
},
"homepage": "http://linkedin.github.io/dustjs/",
"description": "Asynchronous templates for the browser and node.js ( LinkedIn fork )",
"contributors": [
{
"name": "Jairo de Morais",
"email": "jdemorais@linkedin.com"
},
{
"name": "Veena Basavaraj",
"email": "vbasavaraj@linkedin.com"
},
{
"name": "Jimmy Chan",
"email": "jchan@linkedin.com"
},
{
"name": "Richard Ragan",
"email": "rragan@ebay.com"
},
{
"name": "Steven Foote",
"email": "sfoote@linkedin.com"
}
],
"scripts": {
"test": "grunt test"
},
"bin": {
"dustc": "./bin/dustc"
},
"main": "lib/server.js",
"browser": "./lib/dust.js",
"repository": {
"type": "git",
"url": "https://github.com/linkedin/dustjs.git"
},
"keywords": [
"templates",
"views"
],
"devDependencies": {
"pegjs": "0.8.0",
"grunt": "~0.4.2",
"grunt-contrib-connect": "~0.5.0",
"grunt-template-jasmine-istanbul": "~0.2.5",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-gh-pages": "~0.9.0",
"grunt-contrib-compress": "~0.5.3",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-shell": "~0.6.1",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-bump": "0.0.11"
},
"license": "MIT",
"engine": {
"node": ">=0.8"
},
"bugs": {
"url": "https://github.com/linkedin/dustjs/issues"
},
"_id": "dustjs-linkedin@2.4.2",
"dist": {
"shasum": "1db46d7e43df317c597c06b390a0addf05ae0663",
"tarball": "http://registry.npmjs.org/dustjs-linkedin/-/dustjs-linkedin-2.4.2.tgz"
},
"_from": "dustjs-linkedin@2.4.2",
"_npmVersion": "1.4.3",
"_npmUser": {
"name": "linkedin",
"email": "acrabtree@linkedin.com"
},
"maintainers": [
{
"name": "vybs",
"email": "veena.braj@gmail.com"
},
{
"name": "rragan",
"email": "rragan@ebay.com"
},
{
"name": "jimmyhchan",
"email": "jimmyhchan@gmail.com"
},
{
"name": "linkedin",
"email": "acrabtree@linkedin.com"
}
],
"directories": {},
"_shasum": "1db46d7e43df317c597c06b390a0addf05ae0663",
"_resolved": "https://registry.npmjs.org/dustjs-linkedin/-/dustjs-linkedin-2.4.2.tgz"
}

View File

@ -12,7 +12,9 @@
"morgan": "~1.3.0", "morgan": "~1.3.0",
"serve-favicon": "~2.1.3", "serve-favicon": "~2.1.3",
"debug": "~2.0.0", "debug": "~2.0.0",
"dust":"*", "consolidate":"*",
"dustjs-linkedin":"*",
"dustjs-helpers":"*",
"nodeunit":"*", "nodeunit":"*",
"mysql":"*", "mysql":"*",
"node-memcache":"*" "node-memcache":"*"

12
views/error.dust Normal file
View File

@ -0,0 +1,12 @@
{>layout/}
{<content}
<h1>{message}</h1>
<h2>{error.status}</h2>
{#error.stack}
<pre>
{~n}
</pre>
{/error.stack}
{/content}

View File

@ -1,6 +0,0 @@
extends layout
block content
h1= message
h2= error.status
pre #{error.stack}

6
views/index.dust Normal file
View File

@ -0,0 +1,6 @@
{>layout/}
{<content}
<h1>{title}</th>
<p>Welcome to {title}</p>
{/content}

View File

@ -1,5 +0,0 @@
extends layout
block content
h1= title
p Welcome to #{title}

15
views/layout.dust Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
{+content}
This is the base content.
{/content}
</body>
<!--
{session}
-->
</html>

View File

@ -1,7 +0,0 @@
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content