diff --git a/app.js b/app.js index 59e4ade..310d605 100644 --- a/app.js +++ b/app.js @@ -5,12 +5,12 @@ var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); -var routes = require('./routes/index'); -var users = require('./routes/users'); - var app = express(); // 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('view engine', 'dust'); @@ -20,16 +20,19 @@ app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); 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('/users', users); // catch 404 and forward to error handler app.use(function(req, res, next) { - var err = new Error('Not Found'); - err.status = 404; - next(err); + var err = new Error('Not Found'); + err.status = 404; + next(err); }); // error handlers @@ -37,23 +40,23 @@ app.use(function(req, res, next) { // development error handler // will print stacktrace if (app.get('env') === 'development') { - app.use(function(err, req, res, next) { - res.status(err.status || 500); - res.render('error', { - message: err.message, - error: err - }); - }); + app.use(function(err, req, res, next) { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: err + }); + }); } // production error handler // no stacktraces leaked to user app.use(function(err, req, res, next) { - res.status(err.status || 500); - res.render('error', { - message: err.message, - error: {} - }); + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: {} + }); }); diff --git a/node_modules/.bin/dustc b/node_modules/.bin/dustc new file mode 120000 index 0000000..16d7565 --- /dev/null +++ b/node_modules/.bin/dustc @@ -0,0 +1 @@ +../dustjs-linkedin/bin/dustc \ No newline at end of file diff --git a/node_modules/consolidate/.npmignore b/node_modules/consolidate/.npmignore new file mode 100644 index 0000000..f1250e5 --- /dev/null +++ b/node_modules/consolidate/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/node_modules/consolidate/History.md b/node_modules/consolidate/History.md new file mode 100644 index 0000000..66908b3 --- /dev/null +++ b/node_modules/consolidate/History.md @@ -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 diff --git a/node_modules/consolidate/Makefile b/node_modules/consolidate/Makefile new file mode 100644 index 0000000..2bc56b4 --- /dev/null +++ b/node_modules/consolidate/Makefile @@ -0,0 +1,9 @@ + +REPORTER = spec + +test: + @./node_modules/.bin/mocha \ + --slow 30 \ + --reporter $(REPORTER) + +.PHONY: test \ No newline at end of file diff --git a/node_modules/consolidate/Readme.md b/node_modules/consolidate/Readme.md new file mode 100644 index 0000000..d43647e --- /dev/null +++ b/node_modules/consolidate/Readme.md @@ -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. diff --git a/node_modules/consolidate/index.js b/node_modules/consolidate/index.js new file mode 100644 index 0000000..4a0df17 --- /dev/null +++ b/node_modules/consolidate/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/consolidate'); \ No newline at end of file diff --git a/node_modules/consolidate/lib/consolidate.js b/node_modules/consolidate/lib/consolidate.js new file mode 100644 index 0000000..279b7f4 --- /dev/null +++ b/node_modules/consolidate/lib/consolidate.js @@ -0,0 +1,764 @@ +/*! + * consolidate + * Copyright(c) 2012 TJ Holowaychuk + * 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); +}; diff --git a/node_modules/consolidate/package.json b/node_modules/consolidate/package.json new file mode 100644 index 0000000..96d1676 --- /dev/null +++ b/node_modules/consolidate/package.json @@ -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" +} diff --git a/node_modules/dust/.npmignore b/node_modules/dust/.npmignore deleted file mode 100644 index 00495dc..0000000 --- a/node_modules/dust/.npmignore +++ /dev/null @@ -1 +0,0 @@ -/nbproject \ No newline at end of file diff --git a/node_modules/dust/Makefile b/node_modules/dust/Makefile deleted file mode 100644 index 46cd327..0000000 --- a/node_modules/dust/Makefile +++ /dev/null @@ -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 \ No newline at end of file diff --git a/node_modules/dust/README.md b/node_modules/dust/README.md deleted file mode 100644 index e18180b..0000000 --- a/node_modules/dust/README.md +++ /dev/null @@ -1,51 +0,0 @@ -Dust -==== - -> Asynchronous templates for the browser and node.js - -#### # - -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} - { - -Demo & Guide ------------- - -Extensive docs and a full demo are available at \ No newline at end of file diff --git a/node_modules/dust/TODO b/node_modules/dust/TODO deleted file mode 100644 index f9a3f86..0000000 --- a/node_modules/dust/TODO +++ /dev/null @@ -1,3 +0,0 @@ -- Optimize static strings -- Improve interface to compile options (formatting, etc.) -- Refactor compiler \ No newline at end of file diff --git a/node_modules/dust/benchmark/index.html b/node_modules/dust/benchmark/index.html deleted file mode 100644 index 529cd90..0000000 --- a/node_modules/dust/benchmark/index.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - shootout - - - - - - -
-
- -
- -
-
-

Targets: Dust, Handlebars, Mustache, jquery-tmpl. Each benchmark runs once using an adaptive test cycles algorithm similar to the one found in jslitmus.

-
- - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/node_modules/dust/benchmark/server.js b/node_modules/dust/benchmark/server.js deleted file mode 100644 index 72ec2d4..0000000 --- a/node_modules/dust/benchmark/server.js +++ /dev/null @@ -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; ireplace/}{/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: "

{header}

\n" + - "{?items}\n" + - "
    \n" + - " {#items}\n" + - " {#current}\n" + - "
  • {name}
  • \n" + - " {:else}\n" + - "
  • {name}
  • \n" + - " {/current}\n" + - " {/items}\n" + - "
\n" + - "{:else}\n" + - "

The list is empty.

\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); \ No newline at end of file diff --git a/node_modules/dust/benchmark/suites/handlebars_suite.js b/node_modules/dust/benchmark/suites/handlebars_suite.js deleted file mode 100644 index ae0c88d..0000000 --- a/node_modules/dust/benchmark/suites/handlebars_suite.js +++ /dev/null @@ -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: "

{{header}}

{{#hasItems}}
    {{#items}}{{#current}}" + - "
  • {{name}}
  • {{/current}}{{^current}}" + - "
  • {{name}}
  • {{/current}}" + - "{{/items}}
{{^}}

The list is empty.

{{/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); \ No newline at end of file diff --git a/node_modules/dust/benchmark/suites/jquery_suite.js b/node_modules/dust/benchmark/suites/jquery_suite.js deleted file mode 100644 index ee426b7..0000000 --- a/node_modules/dust/benchmark/suites/jquery_suite.js +++ /dev/null @@ -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: "

${header}

{{if items.length}}
    {{each items}}{{if current}}" + - "
  • ${name}
  • {{else}}" + - "
  • ${name}
  • {{/if}}" + - "{{/each}}
{{else}}

The list is empty.

{{/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); \ No newline at end of file diff --git a/node_modules/dust/benchmark/suites/mustache_suite.js b/node_modules/dust/benchmark/suites/mustache_suite.js deleted file mode 100644 index b2aa9c9..0000000 --- a/node_modules/dust/benchmark/suites/mustache_suite.js +++ /dev/null @@ -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: "

{{header}}

{{#hasItems}}
    {{#items}}{{#current}}" + - "
  • {{name}}
  • {{/current}}{{^current}}" + - "
  • {{name}}
  • {{/current}}" + - "{{/items}}
{{/hasItems}}{{^hasItems}}

The list is empty.

{{/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); \ No newline at end of file diff --git a/node_modules/dust/benchmark/uubench.js b/node_modules/dust/benchmark/uubench.js deleted file mode 100644 index b4004a3..0000000 --- a/node_modules/dust/benchmark/uubench.js +++ /dev/null @@ -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\"]/), - AMP = /&/g, - LT = //g, - QUOT = /\"/g; - -dust.escapeHtml = function(s) { - if (typeof s === "string") { - if (!HCHARS.test(s)) { - return s; - } - return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(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; -} diff --git a/node_modules/dust/dist/dust-core-0.3.0.min.js b/node_modules/dust/dist/dust-core-0.3.0.min.js deleted file mode 100644 index cab380b..0000000 --- a/node_modules/dust/dist/dust-core-0.3.0.min.js +++ /dev/null @@ -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\"]/),p=/&/g,q=//g,s=/\"/g;d.escapeHtml=function(a){if(typeof a==="string"){if(!o.test(a))return a;return a.replace(p,"&").replace(q,"<").replace(r,">").replace(s,""")}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}; diff --git a/node_modules/dust/dist/dust-full-0.3.0.js b/node_modules/dust/dist/dust-full-0.3.0.js deleted file mode 100644 index 6d7bdae..0000000 --- a/node_modules/dust/dist/dust-full-0.3.0.js +++ /dev/null @@ -1,3209 +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\"]/), - AMP = /&/g, - LT = //g, - QUOT = /\"/g; - -dust.escapeHtml = function(s) { - if (typeof s === "string") { - if (!HCHARS.test(s)) { - return s; - } - return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(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; -} -(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 rightmostMatchFailuresPos) { - rightmostMatchFailuresPos = pos; - rightmostMatchFailuresExpected = []; - } - - rightmostMatchFailuresExpected.push(failure); - } - - function parse_body() { - var cacheKey = "body" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result1 = []; - var result2 = parse_part(); - while (result2 !== null) { - result1.push(result2); - var result2 = parse_part(); - } - var result0 = result1 !== null - ? (function(p) { return ["body"].concat(p) })(result1) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_part() { - var cacheKey = "part" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result6 = parse_comment(); - if (result6 !== null) { - var result0 = result6; - } else { - var result5 = parse_section(); - if (result5 !== null) { - var result0 = result5; - } else { - var result4 = parse_partial(); - if (result4 !== null) { - var result0 = result4; - } else { - var result3 = parse_special(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_reference(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_buffer(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_section() { - var cacheKey = "section" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos1 = pos; - var result8 = parse_sec_tag_start(); - if (result8 !== null) { - var result9 = parse_rd(); - if (result9 !== null) { - var result10 = parse_body(); - if (result10 !== null) { - var result11 = parse_bodies(); - if (result11 !== null) { - var result12 = parse_end_tag(); - if (result12 !== null) { - var result13 = (function() {return result8[1].text === result12.text})() ? '' : null; - if (result13 !== null) { - var result7 = [result8, result9, result10, result11, result12, result13]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - var result6 = result7 !== null - ? (function(t, b, e, n) { e.push(["param", ["literal", "block"], b]); t.push(e); return t })(result7[0], result7[2], result7[3], result7[4]) - : null; - if (result6 !== null) { - var result0 = result6; - } else { - var savedPos0 = pos; - var result3 = parse_sec_tag_start(); - if (result3 !== null) { - if (input.substr(pos, 1) === "/") { - var result4 = "/"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result2 = [result3, result4, result5]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(t) { t.push(["bodies"]); return t })(result2[0]) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("section"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_sec_tag_start() { - var cacheKey = "sec_tag_start" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos).match(/^[#?^<+@%]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[#?^<+@%]"); - } - } - if (result3 !== null) { - var result4 = parse_identifier(); - if (result4 !== null) { - var result5 = parse_context(); - if (result5 !== null) { - var result6 = parse_params(); - if (result6 !== null) { - var result1 = [result2, result3, result4, result5, result6]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(t, n, c, p) { return [t, n, c, p] })(result1[1], result1[2], result1[3], result1[4]) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_end_tag() { - var cacheKey = "end_tag" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos, 1) === "/") { - var result3 = "/"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result3 !== null) { - var result4 = parse_identifier(); - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(n) { return n })(result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("end tag"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_context() { - var cacheKey = "context" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - if (input.substr(pos, 1) === ":") { - var result4 = ":"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - var result5 = parse_identifier(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(n) {return n})(result3[1]) - : null; - var result1 = result2 !== null ? result2 : ''; - var result0 = result1 !== null - ? (function(n) { return n ? ["context", n] : ["context"] })(result1) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_params() { - var cacheKey = "params" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = []; - var savedPos0 = pos; - var result4 = parse_ws(); - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - if (input.substr(pos, 1) === "=") { - var result6 = "="; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"=\""); - } - } - if (result6 !== null) { - var result9 = parse_identifier(); - if (result9 !== null) { - var result7 = result9; - } else { - var result8 = parse_inline(); - if (result8 !== null) { - var result7 = result8; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - var result3 = [result4, result5, result6, result7]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[1], result3[3]) - : null; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - var result4 = parse_ws(); - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - if (input.substr(pos, 1) === "=") { - var result6 = "="; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"=\""); - } - } - if (result6 !== null) { - var result9 = parse_identifier(); - if (result9 !== null) { - var result7 = result9; - } else { - var result8 = parse_inline(); - if (result8 !== null) { - var result7 = result8; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - var result3 = [result4, result5, result6, result7]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[1], result3[3]) - : null; - } - var result0 = result1 !== null - ? (function(p) { return ["params"].concat(p) })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("params"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_bodies() { - var cacheKey = "bodies" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = []; - var savedPos0 = pos; - var result4 = parse_ld(); - if (result4 !== null) { - if (input.substr(pos, 1) === ":") { - var result5 = ":"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - var result6 = parse_key(); - if (result6 !== null) { - var result7 = parse_rd(); - if (result7 !== null) { - var result8 = parse_body(); - if (result8 !== null) { - var result3 = [result4, result5, result6, result7, result8]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[2], result3[4]) - : null; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - var result4 = parse_ld(); - if (result4 !== null) { - if (input.substr(pos, 1) === ":") { - var result5 = ":"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - var result6 = parse_key(); - if (result6 !== null) { - var result7 = parse_rd(); - if (result7 !== null) { - var result8 = parse_body(); - if (result8 !== null) { - var result3 = [result4, result5, result6, result7, result8]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[2], result3[4]) - : null; - } - var result0 = result1 !== null - ? (function(p) { return ["bodies"].concat(p) })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("bodies"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_reference() { - var cacheKey = "reference" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - var result3 = parse_identifier(); - if (result3 !== null) { - var result4 = parse_filters(); - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(n, f) { return ["reference", n, f] })(result1[1], result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("reference"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_partial() { - var cacheKey = "partial" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos, 1) === ">") { - var result3 = ">"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\">\""); - } - } - if (result3 !== null) { - var result10 = parse_key(); - var result9 = result10 !== null - ? (function(k) {return ["literal", k]})(result10) - : null; - if (result9 !== null) { - var result4 = result9; - } else { - var result8 = parse_inline(); - if (result8 !== null) { - var result4 = result8; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - var result5 = parse_context(); - if (result5 !== null) { - if (input.substr(pos, 1) === "/") { - var result6 = "/"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result6 !== null) { - var result7 = parse_rd(); - if (result7 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(n, c) { return ["partial", n, c] })(result1[2], result1[3]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("partial"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_filters() { - var cacheKey = "filters" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = []; - var savedPos0 = pos; - if (input.substr(pos, 1) === "|") { - var result4 = "|"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(n) {return n})(result3[1]) - : null; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - if (input.substr(pos, 1) === "|") { - var result4 = "|"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(n) {return n})(result3[1]) - : null; - } - var result0 = result1 !== null - ? (function(f) { return ["filters"].concat(f) })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("filters"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_special() { - var cacheKey = "special" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos, 1) === "~") { - var result3 = "~"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"~\""); - } - } - if (result3 !== null) { - var result4 = parse_key(); - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(k) { return ["special", k] })(result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("special"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_identifier() { - var cacheKey = "identifier" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result4 = parse_path(); - var result3 = result4 !== null - ? (function(p) { return wrap(["path"].concat(p), cacheKey) })(result4) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_key(); - var result1 = result2 !== null - ? (function(k) { return wrap(["key", k], cacheKey) })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("identifier"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_path() { - var cacheKey = "path" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result11 = parse_key(); - var result5 = result11 !== null ? result11 : ''; - if (result5 !== null) { - var savedPos1 = pos; - if (input.substr(pos, 1) === ".") { - var result9 = "."; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result9 !== null) { - var result10 = parse_key(); - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - var result7 = result8 !== null - ? (function(k) {return k})(result8[1]) - : null; - if (result7 !== null) { - var result6 = []; - while (result7 !== null) { - result6.push(result7); - var savedPos1 = pos; - if (input.substr(pos, 1) === ".") { - var result9 = "."; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result9 !== null) { - var result10 = parse_key(); - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - var result7 = result8 !== null - ? (function(k) {return k})(result8[1]) - : null; - } - } else { - var result6 = null; - } - if (result6 !== null) { - var result4 = [result5, result6]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(k, d) { - if (k) { d.unshift(k); return [false, d]; } - return [true, d]; - })(result4[0], result4[1]) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos, 1) === ".") { - var result2 = "."; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - var result1 = result2 !== null - ? (function() { return [true, []] })() - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("path"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_key() { - var cacheKey = "key" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos).match(/^[a-zA-Z_$]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z_$]"); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[0-9a-zA-Z_$]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[0-9a-zA-Z_$]"); - } - } - while (result4 !== null) { - result3.push(result4); - if (input.substr(pos).match(/^[0-9a-zA-Z_$]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[0-9a-zA-Z_$]"); - } - } - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(h, t) { return h + t.join('') })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("key"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_inline() { - var cacheKey = "inline" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos2 = pos; - if (input.substr(pos, 1) === "\"") { - var result14 = "\""; - pos += 1; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result14 !== null) { - if (input.substr(pos, 1) === "\"") { - var result15 = "\""; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result15 !== null) { - var result13 = [result14, result15]; - } else { - var result13 = null; - pos = savedPos2; - } - } else { - var result13 = null; - pos = savedPos2; - } - var result12 = result13 !== null - ? (function() { return ["literal", ""] })() - : null; - if (result12 !== null) { - var result0 = result12; - } else { - var savedPos1 = pos; - if (input.substr(pos, 1) === "\"") { - var result9 = "\""; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result9 !== null) { - var result10 = parse_literal(); - if (result10 !== null) { - if (input.substr(pos, 1) === "\"") { - var result11 = "\""; - pos += 1; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result11 !== null) { - var result8 = [result9, result10, result11]; - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - var result7 = result8 !== null - ? (function(l) { return ["literal", l] })(result8[1]) - : null; - if (result7 !== null) { - var result0 = result7; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "\"") { - var result3 = "\""; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result3 !== null) { - var result6 = parse_inline_part(); - if (result6 !== null) { - var result4 = []; - while (result6 !== null) { - result4.push(result6); - var result6 = parse_inline_part(); - } - } else { - var result4 = null; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "\"") { - var result5 = "\""; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result5 !== null) { - var result2 = [result3, result4, result5]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(p) { return ["body"].concat(p) })(result2[1]) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("inline"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_inline_part() { - var cacheKey = "inline_part" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result4 = parse_special(); - if (result4 !== null) { - var result0 = result4; - } else { - var result3 = parse_reference(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_literal(); - var result1 = result2 !== null - ? (function(l) { return ["buffer", l] })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_buffer() { - var cacheKey = "buffer" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos4 = pos; - var result14 = parse_eol(); - if (result14 !== null) { - var result15 = []; - var result16 = parse_ws(); - while (result16 !== null) { - result15.push(result16); - var result16 = parse_ws(); - } - if (result15 !== null) { - var result13 = [result14, result15]; - } else { - var result13 = null; - pos = savedPos4; - } - } else { - var result13 = null; - pos = savedPos4; - } - var result12 = result13 !== null - ? (function(e, w) { return ["format", e, w.join('')] })(result13[0], result13[1]) - : null; - if (result12 !== null) { - var result0 = result12; - } else { - var savedPos0 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar2 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar2; - if (result11 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos3; - } - if (result5 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result6 = ''; - } else { - var result6 = null; - pos = savedPos2; - } - if (result6 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_comment(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos1; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result4 = [result5, result6, result7, result8]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(c) {return c})(result4[3]) - : null; - if (result3 !== null) { - var result2 = []; - while (result3 !== null) { - result2.push(result3); - var savedPos0 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar2 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar2; - if (result11 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos3; - } - if (result5 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result6 = ''; - } else { - var result6 = null; - pos = savedPos2; - } - if (result6 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_comment(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos1; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result4 = [result5, result6, result7, result8]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(c) {return c})(result4[3]) - : null; - } - } else { - var result2 = null; - } - var result1 = result2 !== null - ? (function(b) { return ["buffer", b.join('')] })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("buffer"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_literal() { - var cacheKey = "literal" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result4 = ''; - } else { - var result4 = null; - pos = savedPos2; - } - if (result4 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos1; - } - if (result5 !== null) { - var result8 = parse_esc(); - if (result8 !== null) { - var result6 = result8; - } else { - if (input.substr(pos).match(/^[^"]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"]"); - } - } - if (result7 !== null) { - var result6 = result7; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - var result3 = [result4, result5, result6]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(c) {return c})(result3[2]) - : null; - if (result2 !== null) { - var result1 = []; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result4 = ''; - } else { - var result4 = null; - pos = savedPos2; - } - if (result4 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos1; - } - if (result5 !== null) { - var result8 = parse_esc(); - if (result8 !== null) { - var result6 = result8; - } else { - if (input.substr(pos).match(/^[^"]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"]"); - } - } - if (result7 !== null) { - var result6 = result7; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - var result3 = [result4, result5, result6]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(c) {return c})(result3[2]) - : null; - } - } else { - var result1 = null; - } - var result0 = result1 !== null - ? (function(b) { return b.join('') })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("literal"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_esc() { - var cacheKey = "esc" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 2) === "\\\"") { - var result1 = "\\\""; - pos += 2; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"\\\\\\\"\""); - } - } - var result0 = result1 !== null - ? (function() { return '"' })() - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_comment() { - var cacheKey = "comment" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 2) === "{!") { - var result2 = "{!"; - pos += 2; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"{!\""); - } - } - if (result2 !== null) { - var result3 = []; - var savedPos1 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos, 2) === "!}") { - var result9 = "!}"; - pos += 2; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"!}\""); - } - } - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos2; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result6 = [result7, result8]; - } else { - var result6 = null; - pos = savedPos1; - } - } else { - var result6 = null; - pos = savedPos1; - } - var result5 = result6 !== null - ? (function(c) {return c})(result6[1]) - : null; - while (result5 !== null) { - result3.push(result5); - var savedPos1 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos, 2) === "!}") { - var result9 = "!}"; - pos += 2; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"!}\""); - } - } - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos2; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result6 = [result7, result8]; - } else { - var result6 = null; - pos = savedPos1; - } - } else { - var result6 = null; - pos = savedPos1; - } - var result5 = result6 !== null - ? (function(c) {return c})(result6[1]) - : null; - } - if (result3 !== null) { - if (input.substr(pos, 2) === "!}") { - var result4 = "!}"; - pos += 2; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"!}\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(c) { return ["comment", c.join('')] })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("comment"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_tag() { - var cacheKey = "tag" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - var result3 = parse_ld(); - if (result3 !== null) { - if (input.substr(pos).match(/^[#?^><+%:@\/~%]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[#?^><+%:@\\/~%]"); - } - } - if (result4 !== null) { - var savedPos1 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result12 = parse_rd(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result12 === null) { - var result8 = ''; - } else { - var result8 = null; - pos = savedPos3; - } - if (result8 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result11 === null) { - var result9 = ''; - } else { - var result9 = null; - pos = savedPos2; - } - if (result9 !== null) { - if (input.length > pos) { - var result10 = input.charAt(pos); - pos++; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result10 !== null) { - var result7 = [result8, result9, result10]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - if (result7 !== null) { - var result5 = []; - while (result7 !== null) { - result5.push(result7); - var savedPos1 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result12 = parse_rd(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result12 === null) { - var result8 = ''; - } else { - var result8 = null; - pos = savedPos3; - } - if (result8 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result11 === null) { - var result9 = ''; - } else { - var result9 = null; - pos = savedPos2; - } - if (result9 !== null) { - if (input.length > pos) { - var result10 = input.charAt(pos); - pos++; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result10 !== null) { - var result7 = [result8, result9, result10]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } - } else { - var result5 = null; - } - if (result5 !== null) { - var result6 = parse_rd(); - if (result6 !== null) { - var result2 = [result3, result4, result5, result6]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_reference(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_ld() { - var cacheKey = "ld" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 1) === "{") { - var result0 = "{"; - pos += 1; - } else { - var result0 = null; - if (reportMatchFailures) { - matchFailed("\"{\""); - } - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_rd() { - var cacheKey = "rd" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 1) === "}") { - var result0 = "}"; - pos += 1; - } else { - var result0 = null; - if (reportMatchFailures) { - matchFailed("\"}\""); - } - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_eol() { - var cacheKey = "eol" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 1) === "\n") { - var result5 = "\n"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\"\\n\""); - } - } - if (result5 !== null) { - var result0 = result5; - } else { - if (input.substr(pos, 2) === "\r\n") { - var result4 = "\r\n"; - pos += 2; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"\\r\\n\""); - } - } - if (result4 !== null) { - var result0 = result4; - } else { - if (input.substr(pos, 1) === "\r") { - var result3 = "\r"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"\\r\""); - } - } - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos, 1) === "\u2028") { - var result2 = "\u2028"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"\\u2028\""); - } - } - if (result2 !== null) { - var result0 = result2; - } else { - if (input.substr(pos, 1) === "\u2029") { - var result1 = "\u2029"; - pos += 1; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"\\u2029\""); - } - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_ws() { - var cacheKey = "ws" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos).match(/^[ \xA0\uFEFF]/) !== null) { - var result0 = input.charAt(pos); - pos++; - } else { - var result0 = null; - if (reportMatchFailures) { - matchFailed("[ \\xA0\\uFEFF]"); - } - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function buildErrorMessage() { - function buildExpected(failuresExpected) { - failuresExpected.sort(); - - var lastFailure = null; - var failuresExpectedUnique = []; - for (var i = 0; i < failuresExpected.length; i++) { - if (failuresExpected[i] !== lastFailure) { - failuresExpectedUnique.push(failuresExpected[i]); - lastFailure = failuresExpected[i]; - } - } - - switch (failuresExpectedUnique.length) { - case 0: - return 'end of input'; - case 1: - return failuresExpectedUnique[0]; - default: - return failuresExpectedUnique.slice(0, failuresExpectedUnique.length - 1).join(', ') - + ' or ' - + failuresExpectedUnique[failuresExpectedUnique.length - 1]; - } - } - - var expected = buildExpected(rightmostMatchFailuresExpected); - var actualPos = Math.max(pos, rightmostMatchFailuresPos); - var actual = actualPos < input.length - ? quote(input.charAt(actualPos)) - : 'end of input'; - - return 'Expected ' + expected + ' but ' + actual + ' found.'; - } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < rightmostMatchFailuresPos; i++) { - var ch = input.charAt(i); - if (ch === '\n') { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === '\r' | ch === '\u2028' || ch === '\u2029') { - line++; - column = 1; - seenCR = true; - } else { - column++; - seenCR = false; - } - } - - return { line: line, column: column }; - } - - - - function wrap(node, ck) { - - node['text'] = input.substring(ck.split('@')[1], pos); - - return node; - - } - - - - var result = parse_body(); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostMatchFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostMatchFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostMatchFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var errorPosition = computeErrorPosition(); - throw new SyntaxError( - buildErrorMessage(), - errorPosition.line, - errorPosition.column - ); - } - - return result; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(message, line, column) { - this.name = 'SyntaxError'; - this.message = message; - this.line = line; - this.column = column; - }; - - result.SyntaxError.prototype = Error.prototype; - - return result; -})(); - -dust.parse = parser.parse; - -})(typeof exports !== 'undefined' ? exports : window.dust); \ No newline at end of file diff --git a/node_modules/dust/dist/dust-full-0.3.0.min.js b/node_modules/dust/dist/dust-full-0.3.0.min.js deleted file mode 100644 index ba21d94..0000000 --- a/node_modules/dust/dist/dust-full-0.3.0.min.js +++ /dev/null @@ -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\"]/),q=/&/g,j=//g,t=/\"/g;o.escapeHtml=function(e){if(typeof e==="string"){if(!K.test(e))return e;return e.replace(q,"&").replace(j,"<").replace(w,">").replace(t,""")}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;tR){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 - - -Include the full distribution if you want to compile templates within the browser (as in the online demo): - - - -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`. \ No newline at end of file diff --git a/node_modules/dust/docs/build.js b/node_modules/dust/docs/build.js deleted file mode 100644 index 2ea53a2..0000000 --- a/node_modules/dust/docs/build.js +++ /dev/null @@ -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 = ""; - return out; - }, - - js: function(names) { - var out = ""; - 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 = ""; - 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(); \ No newline at end of file diff --git a/node_modules/dust/docs/index.css b/node_modules/dust/docs/index.css deleted file mode 100644 index 81ca035..0000000 --- a/node_modules/dust/docs/index.css +++ /dev/null @@ -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 } \ No newline at end of file diff --git a/node_modules/dust/docs/index.dust.html b/node_modules/dust/docs/index.dust.html deleted file mode 100644 index 0107408..0000000 --- a/node_modules/dust/docs/index.dust.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - dust - - - {#inline names="index" ext="css"/} - - - - - - - - - - - {#tmpl names="select"/} - {#inline names="index" ext="js"/} - - -
-
-
-

{~lb}dust{~rb}

- asynchronous streaming templates for the browser and node.js -
- -
-

1. Select a template or write your own:

- -
Ready
-

2. The compiled template registers itself by name:

-
-

When you're done messing around have a look at the guide.

-
-
-

3. Control template behavior with contexts and helpers:

- -
Ready
-

4. Render or stream the result:

-

-        
-
-
-
-
-
-

{~lb}guide{~rb}

-
-
- {#md}{#file name="syntax.md"/}{/md} -
-
- {#md}{#file name="api.md"/}{/md} -
-
-
-
-
-
-

{~lb}tests{~rb}

-
-
-

If the console below indicates an error then we have a problem.

-

-        
-
-

Interested in seeing how Dust stacks up against similar templating engines? Have a look at the live benchmarks.

-
-
-
-
-
-
-

{~lb}about{~rb}

-
-
- {#md}{#file name="about.md"/}{/md} -
-
-

Dust was created by akdubya.

-

This page is powered by Dust, jQuery, showdown, beautify.js, jsDump and hijs. -

-
-
- - - \ No newline at end of file diff --git a/node_modules/dust/docs/index.js b/node_modules/dust/docs/index.js deleted file mode 100644 index d1baaef..0000000 --- a/node_modules/dust/docs/index.js +++ /dev/null @@ -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(); - -}); \ No newline at end of file diff --git a/node_modules/dust/docs/select.dust.html b/node_modules/dust/docs/select.dust.html deleted file mode 100644 index 130f384..0000000 --- a/node_modules/dust/docs/select.dust.html +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/node_modules/dust/docs/syntax.md b/node_modules/dust/docs/syntax.md deleted file mode 100644 index cef4423..0000000 --- a/node_modules/dust/docs/syntax.md +++ /dev/null @@ -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: - - - -This would be rendered as: - - <script>alert('I am evil!')</script> - -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} -
    - {#tags} -
  • {.}
  • - {/tags} -
- {: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 (`{base_template/} - {base_template/} - {:else} - {+main/} - {/xhr} - {dust

{dust}

asynchronous streaming templates for the browser and node.js

1. Select a template or write your own:

Ready

2. The compiled template registers itself by name:

When you're done messing around have a look at the guide.

3. Control template behavior with contexts and helpers:

Ready

4. Render or stream the result:

{guide}

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
-

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:

- -
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.

{tests}

If the console below indicates an error then we have a problem.

Interested in seeing how Dust stacks up against similar templating engines? Have a look at the live benchmarks.

{about}

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.

Dust was created by akdubya.

This page is powered by Dust, jQuery, showdown, beautify.js, jsDump and hijs.

\ No newline at end of file diff --git a/node_modules/dust/lib/compiler.js b/node_modules/dust/lib/compiler.js deleted file mode 100644 index 9eaef40..0000000 --- a/node_modules/dust/lib/compiler.js +++ /dev/null @@ -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\"]/), - AMP = /&/g, - LT = //g, - QUOT = /\"/g; - -dust.escapeHtml = function(s) { - if (typeof s === "string") { - if (!HCHARS.test(s)) { - return s; - } - return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(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; -} diff --git a/node_modules/dust/lib/parser.js b/node_modules/dust/lib/parser.js deleted file mode 100644 index 313781d..0000000 --- a/node_modules/dust/lib/parser.js +++ /dev/null @@ -1,2368 +0,0 @@ -(function(dust){ - -var parser = (function(){ - /* Generated by PEG.js (http://pegjs.majda.cz/). */ - - var result = { - /* - * Parses the input with a generated parser. If the parsing is successfull, - * returns a value explicitly or implicitly specified by the grammar from - * which the parser was generated (see |PEG.buildParser|). If the parsing is - * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. - */ - parse: function(input) { - var pos = 0; - var reportMatchFailures = true; - var rightmostMatchFailuresPos = 0; - var rightmostMatchFailuresExpected = []; - var cache = {}; - - function padLeft(input, padding, length) { - var result = input; - - var padLength = length - input.length; - for (var i = 0; i < padLength; i++) { - result = padding + result; - } - - return result; - } - - function escape(ch) { - var charCode = ch.charCodeAt(0); - - if (charCode < 0xFF) { - var escapeChar = 'x'; - var length = 2; - } else { - var escapeChar = 'u'; - var length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); - } - - function quote(s) { - /* - * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a - * string literal except for the closing quote character, backslash, - * carriage return, line separator, paragraph separator, and line feed. - * Any character may appear in the form of an escape sequence. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\r/g, '\\r') // carriage return - .replace(/\n/g, '\\n') // line feed - .replace(/[\x80-\uFFFF]/g, escape) // non-ASCII characters - + '"'; - } - - function matchFailed(failure) { - if (pos < rightmostMatchFailuresPos) { - return; - } - - if (pos > rightmostMatchFailuresPos) { - rightmostMatchFailuresPos = pos; - rightmostMatchFailuresExpected = []; - } - - rightmostMatchFailuresExpected.push(failure); - } - - function parse_body() { - var cacheKey = "body" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result1 = []; - var result2 = parse_part(); - while (result2 !== null) { - result1.push(result2); - var result2 = parse_part(); - } - var result0 = result1 !== null - ? (function(p) { return ["body"].concat(p) })(result1) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_part() { - var cacheKey = "part" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result6 = parse_comment(); - if (result6 !== null) { - var result0 = result6; - } else { - var result5 = parse_section(); - if (result5 !== null) { - var result0 = result5; - } else { - var result4 = parse_partial(); - if (result4 !== null) { - var result0 = result4; - } else { - var result3 = parse_special(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_reference(); - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_buffer(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_section() { - var cacheKey = "section" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos1 = pos; - var result8 = parse_sec_tag_start(); - if (result8 !== null) { - var result9 = parse_rd(); - if (result9 !== null) { - var result10 = parse_body(); - if (result10 !== null) { - var result11 = parse_bodies(); - if (result11 !== null) { - var result12 = parse_end_tag(); - if (result12 !== null) { - var result13 = (function() {return result8[1].text === result12.text})() ? '' : null; - if (result13 !== null) { - var result7 = [result8, result9, result10, result11, result12, result13]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - var result6 = result7 !== null - ? (function(t, b, e, n) { e.push(["param", ["literal", "block"], b]); t.push(e); return t })(result7[0], result7[2], result7[3], result7[4]) - : null; - if (result6 !== null) { - var result0 = result6; - } else { - var savedPos0 = pos; - var result3 = parse_sec_tag_start(); - if (result3 !== null) { - if (input.substr(pos, 1) === "/") { - var result4 = "/"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result2 = [result3, result4, result5]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(t) { t.push(["bodies"]); return t })(result2[0]) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("section"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_sec_tag_start() { - var cacheKey = "sec_tag_start" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos).match(/^[#?^<+@%]/) !== null) { - var result3 = input.charAt(pos); - pos++; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("[#?^<+@%]"); - } - } - if (result3 !== null) { - var result4 = parse_identifier(); - if (result4 !== null) { - var result5 = parse_context(); - if (result5 !== null) { - var result6 = parse_params(); - if (result6 !== null) { - var result1 = [result2, result3, result4, result5, result6]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(t, n, c, p) { return [t, n, c, p] })(result1[1], result1[2], result1[3], result1[4]) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_end_tag() { - var cacheKey = "end_tag" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos, 1) === "/") { - var result3 = "/"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result3 !== null) { - var result4 = parse_identifier(); - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(n) { return n })(result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("end tag"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_context() { - var cacheKey = "context" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - if (input.substr(pos, 1) === ":") { - var result4 = ":"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - var result5 = parse_identifier(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(n) {return n})(result3[1]) - : null; - var result1 = result2 !== null ? result2 : ''; - var result0 = result1 !== null - ? (function(n) { return n ? ["context", n] : ["context"] })(result1) - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_params() { - var cacheKey = "params" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = []; - var savedPos0 = pos; - var result4 = parse_ws(); - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - if (input.substr(pos, 1) === "=") { - var result6 = "="; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"=\""); - } - } - if (result6 !== null) { - var result9 = parse_identifier(); - if (result9 !== null) { - var result7 = result9; - } else { - var result8 = parse_inline(); - if (result8 !== null) { - var result7 = result8; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - var result3 = [result4, result5, result6, result7]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[1], result3[3]) - : null; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - var result4 = parse_ws(); - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - if (input.substr(pos, 1) === "=") { - var result6 = "="; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"=\""); - } - } - if (result6 !== null) { - var result9 = parse_identifier(); - if (result9 !== null) { - var result7 = result9; - } else { - var result8 = parse_inline(); - if (result8 !== null) { - var result7 = result8; - } else { - var result7 = null;; - }; - } - if (result7 !== null) { - var result3 = [result4, result5, result6, result7]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[1], result3[3]) - : null; - } - var result0 = result1 !== null - ? (function(p) { return ["params"].concat(p) })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("params"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_bodies() { - var cacheKey = "bodies" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = []; - var savedPos0 = pos; - var result4 = parse_ld(); - if (result4 !== null) { - if (input.substr(pos, 1) === ":") { - var result5 = ":"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - var result6 = parse_key(); - if (result6 !== null) { - var result7 = parse_rd(); - if (result7 !== null) { - var result8 = parse_body(); - if (result8 !== null) { - var result3 = [result4, result5, result6, result7, result8]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[2], result3[4]) - : null; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - var result4 = parse_ld(); - if (result4 !== null) { - if (input.substr(pos, 1) === ":") { - var result5 = ":"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - var result6 = parse_key(); - if (result6 !== null) { - var result7 = parse_rd(); - if (result7 !== null) { - var result8 = parse_body(); - if (result8 !== null) { - var result3 = [result4, result5, result6, result7, result8]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(k, v) {return ["param", ["literal", k], v]})(result3[2], result3[4]) - : null; - } - var result0 = result1 !== null - ? (function(p) { return ["bodies"].concat(p) })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("bodies"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_reference() { - var cacheKey = "reference" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - var result3 = parse_identifier(); - if (result3 !== null) { - var result4 = parse_filters(); - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(n, f) { return ["reference", n, f] })(result1[1], result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("reference"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_partial() { - var cacheKey = "partial" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos, 1) === ">") { - var result3 = ">"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\">\""); - } - } - if (result3 !== null) { - var result10 = parse_key(); - var result9 = result10 !== null - ? (function(k) {return ["literal", k]})(result10) - : null; - if (result9 !== null) { - var result4 = result9; - } else { - var result8 = parse_inline(); - if (result8 !== null) { - var result4 = result8; - } else { - var result4 = null;; - }; - } - if (result4 !== null) { - var result5 = parse_context(); - if (result5 !== null) { - if (input.substr(pos, 1) === "/") { - var result6 = "/"; - pos += 1; - } else { - var result6 = null; - if (reportMatchFailures) { - matchFailed("\"/\""); - } - } - if (result6 !== null) { - var result7 = parse_rd(); - if (result7 !== null) { - var result1 = [result2, result3, result4, result5, result6, result7]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(n, c) { return ["partial", n, c] })(result1[2], result1[3]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("partial"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_filters() { - var cacheKey = "filters" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result1 = []; - var savedPos0 = pos; - if (input.substr(pos, 1) === "|") { - var result4 = "|"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(n) {return n})(result3[1]) - : null; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - if (input.substr(pos, 1) === "|") { - var result4 = "|"; - pos += 1; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"|\""); - } - } - if (result4 !== null) { - var result5 = parse_key(); - if (result5 !== null) { - var result3 = [result4, result5]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(n) {return n})(result3[1]) - : null; - } - var result0 = result1 !== null - ? (function(f) { return ["filters"].concat(f) })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("filters"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_special() { - var cacheKey = "special" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result2 = parse_ld(); - if (result2 !== null) { - if (input.substr(pos, 1) === "~") { - var result3 = "~"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"~\""); - } - } - if (result3 !== null) { - var result4 = parse_key(); - if (result4 !== null) { - var result5 = parse_rd(); - if (result5 !== null) { - var result1 = [result2, result3, result4, result5]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(k) { return ["special", k] })(result1[2]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("special"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_identifier() { - var cacheKey = "identifier" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var result4 = parse_path(); - var result3 = result4 !== null - ? (function(p) { return wrap(["path"].concat(p), cacheKey) })(result4) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_key(); - var result1 = result2 !== null - ? (function(k) { return wrap(["key", k], cacheKey) })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("identifier"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_path() { - var cacheKey = "path" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var result11 = parse_key(); - var result5 = result11 !== null ? result11 : ''; - if (result5 !== null) { - var savedPos1 = pos; - if (input.substr(pos, 1) === ".") { - var result9 = "."; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result9 !== null) { - var result10 = parse_key(); - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - var result7 = result8 !== null - ? (function(k) {return k})(result8[1]) - : null; - if (result7 !== null) { - var result6 = []; - while (result7 !== null) { - result6.push(result7); - var savedPos1 = pos; - if (input.substr(pos, 1) === ".") { - var result9 = "."; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - if (result9 !== null) { - var result10 = parse_key(); - if (result10 !== null) { - var result8 = [result9, result10]; - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - var result7 = result8 !== null - ? (function(k) {return k})(result8[1]) - : null; - } - } else { - var result6 = null; - } - if (result6 !== null) { - var result4 = [result5, result6]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(k, d) { - if (k) { d.unshift(k); return [false, d]; } - return [true, d]; - })(result4[0], result4[1]) - : null; - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos, 1) === ".") { - var result2 = "."; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\".\""); - } - } - var result1 = result2 !== null - ? (function() { return [true, []] })() - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("path"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_key() { - var cacheKey = "key" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos).match(/^[a-zA-Z_$]/) !== null) { - var result2 = input.charAt(pos); - pos++; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("[a-zA-Z_$]"); - } - } - if (result2 !== null) { - var result3 = []; - if (input.substr(pos).match(/^[0-9a-zA-Z_$]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[0-9a-zA-Z_$]"); - } - } - while (result4 !== null) { - result3.push(result4); - if (input.substr(pos).match(/^[0-9a-zA-Z_$]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[0-9a-zA-Z_$]"); - } - } - } - if (result3 !== null) { - var result1 = [result2, result3]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(h, t) { return h + t.join('') })(result1[0], result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("key"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_inline() { - var cacheKey = "inline" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos2 = pos; - if (input.substr(pos, 1) === "\"") { - var result14 = "\""; - pos += 1; - } else { - var result14 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result14 !== null) { - if (input.substr(pos, 1) === "\"") { - var result15 = "\""; - pos += 1; - } else { - var result15 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result15 !== null) { - var result13 = [result14, result15]; - } else { - var result13 = null; - pos = savedPos2; - } - } else { - var result13 = null; - pos = savedPos2; - } - var result12 = result13 !== null - ? (function() { return ["literal", ""] })() - : null; - if (result12 !== null) { - var result0 = result12; - } else { - var savedPos1 = pos; - if (input.substr(pos, 1) === "\"") { - var result9 = "\""; - pos += 1; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result9 !== null) { - var result10 = parse_literal(); - if (result10 !== null) { - if (input.substr(pos, 1) === "\"") { - var result11 = "\""; - pos += 1; - } else { - var result11 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result11 !== null) { - var result8 = [result9, result10, result11]; - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - } else { - var result8 = null; - pos = savedPos1; - } - var result7 = result8 !== null - ? (function(l) { return ["literal", l] })(result8[1]) - : null; - if (result7 !== null) { - var result0 = result7; - } else { - var savedPos0 = pos; - if (input.substr(pos, 1) === "\"") { - var result3 = "\""; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result3 !== null) { - var result6 = parse_inline_part(); - if (result6 !== null) { - var result4 = []; - while (result6 !== null) { - result4.push(result6); - var result6 = parse_inline_part(); - } - } else { - var result4 = null; - } - if (result4 !== null) { - if (input.substr(pos, 1) === "\"") { - var result5 = "\""; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\"\\\"\""); - } - } - if (result5 !== null) { - var result2 = [result3, result4, result5]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - var result1 = result2 !== null - ? (function(p) { return ["body"].concat(p) })(result2[1]) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("inline"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_inline_part() { - var cacheKey = "inline_part" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var result4 = parse_special(); - if (result4 !== null) { - var result0 = result4; - } else { - var result3 = parse_reference(); - if (result3 !== null) { - var result0 = result3; - } else { - var result2 = parse_literal(); - var result1 = result2 !== null - ? (function(l) { return ["buffer", l] })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_buffer() { - var cacheKey = "buffer" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos4 = pos; - var result14 = parse_eol(); - if (result14 !== null) { - var result15 = []; - var result16 = parse_ws(); - while (result16 !== null) { - result15.push(result16); - var result16 = parse_ws(); - } - if (result15 !== null) { - var result13 = [result14, result15]; - } else { - var result13 = null; - pos = savedPos4; - } - } else { - var result13 = null; - pos = savedPos4; - } - var result12 = result13 !== null - ? (function(e, w) { return ["format", e, w.join('')] })(result13[0], result13[1]) - : null; - if (result12 !== null) { - var result0 = result12; - } else { - var savedPos0 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar2 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar2; - if (result11 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos3; - } - if (result5 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result6 = ''; - } else { - var result6 = null; - pos = savedPos2; - } - if (result6 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_comment(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos1; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result4 = [result5, result6, result7, result8]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(c) {return c})(result4[3]) - : null; - if (result3 !== null) { - var result2 = []; - while (result3 !== null) { - result2.push(result3); - var savedPos0 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar2 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar2; - if (result11 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos3; - } - if (result5 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result6 = ''; - } else { - var result6 = null; - pos = savedPos2; - } - if (result6 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_comment(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos1; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result4 = [result5, result6, result7, result8]; - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - } else { - var result4 = null; - pos = savedPos0; - } - var result3 = result4 !== null - ? (function(c) {return c})(result4[3]) - : null; - } - } else { - var result2 = null; - } - var result1 = result2 !== null - ? (function(b) { return ["buffer", b.join('')] })(result2) - : null; - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("buffer"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_literal() { - var cacheKey = "literal" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result4 = ''; - } else { - var result4 = null; - pos = savedPos2; - } - if (result4 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos1; - } - if (result5 !== null) { - var result8 = parse_esc(); - if (result8 !== null) { - var result6 = result8; - } else { - if (input.substr(pos).match(/^[^"]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"]"); - } - } - if (result7 !== null) { - var result6 = result7; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - var result3 = [result4, result5, result6]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(c) {return c})(result3[2]) - : null; - if (result2 !== null) { - var result1 = []; - while (result2 !== null) { - result1.push(result2); - var savedPos0 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result10 = parse_tag(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result10 === null) { - var result4 = ''; - } else { - var result4 = null; - pos = savedPos2; - } - if (result4 !== null) { - var savedPos1 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result9 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result5 = ''; - } else { - var result5 = null; - pos = savedPos1; - } - if (result5 !== null) { - var result8 = parse_esc(); - if (result8 !== null) { - var result6 = result8; - } else { - if (input.substr(pos).match(/^[^"]/) !== null) { - var result7 = input.charAt(pos); - pos++; - } else { - var result7 = null; - if (reportMatchFailures) { - matchFailed("[^\"]"); - } - } - if (result7 !== null) { - var result6 = result7; - } else { - var result6 = null;; - }; - } - if (result6 !== null) { - var result3 = [result4, result5, result6]; - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - } else { - var result3 = null; - pos = savedPos0; - } - var result2 = result3 !== null - ? (function(c) {return c})(result3[2]) - : null; - } - } else { - var result1 = null; - } - var result0 = result1 !== null - ? (function(b) { return b.join('') })(result1) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("literal"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_esc() { - var cacheKey = "esc" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 2) === "\\\"") { - var result1 = "\\\""; - pos += 2; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"\\\\\\\"\""); - } - } - var result0 = result1 !== null - ? (function() { return '"' })() - : null; - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_comment() { - var cacheKey = "comment" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - var savedReportMatchFailures = reportMatchFailures; - reportMatchFailures = false; - var savedPos0 = pos; - if (input.substr(pos, 2) === "{!") { - var result2 = "{!"; - pos += 2; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"{!\""); - } - } - if (result2 !== null) { - var result3 = []; - var savedPos1 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos, 2) === "!}") { - var result9 = "!}"; - pos += 2; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"!}\""); - } - } - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos2; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result6 = [result7, result8]; - } else { - var result6 = null; - pos = savedPos1; - } - } else { - var result6 = null; - pos = savedPos1; - } - var result5 = result6 !== null - ? (function(c) {return c})(result6[1]) - : null; - while (result5 !== null) { - result3.push(result5); - var savedPos1 = pos; - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - if (input.substr(pos, 2) === "!}") { - var result9 = "!}"; - pos += 2; - } else { - var result9 = null; - if (reportMatchFailures) { - matchFailed("\"!}\""); - } - } - reportMatchFailures = savedReportMatchFailuresVar0; - if (result9 === null) { - var result7 = ''; - } else { - var result7 = null; - pos = savedPos2; - } - if (result7 !== null) { - if (input.length > pos) { - var result8 = input.charAt(pos); - pos++; - } else { - var result8 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result8 !== null) { - var result6 = [result7, result8]; - } else { - var result6 = null; - pos = savedPos1; - } - } else { - var result6 = null; - pos = savedPos1; - } - var result5 = result6 !== null - ? (function(c) {return c})(result6[1]) - : null; - } - if (result3 !== null) { - if (input.substr(pos, 2) === "!}") { - var result4 = "!}"; - pos += 2; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"!}\""); - } - } - if (result4 !== null) { - var result1 = [result2, result3, result4]; - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - } else { - var result1 = null; - pos = savedPos0; - } - var result0 = result1 !== null - ? (function(c) { return ["comment", c.join('')] })(result1[1]) - : null; - reportMatchFailures = savedReportMatchFailures; - if (reportMatchFailures && result0 === null) { - matchFailed("comment"); - } - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_tag() { - var cacheKey = "tag" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - var savedPos0 = pos; - var result3 = parse_ld(); - if (result3 !== null) { - if (input.substr(pos).match(/^[#?^><+%:@\/~%]/) !== null) { - var result4 = input.charAt(pos); - pos++; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("[#?^><+%:@\\/~%]"); - } - } - if (result4 !== null) { - var savedPos1 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result12 = parse_rd(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result12 === null) { - var result8 = ''; - } else { - var result8 = null; - pos = savedPos3; - } - if (result8 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result11 === null) { - var result9 = ''; - } else { - var result9 = null; - pos = savedPos2; - } - if (result9 !== null) { - if (input.length > pos) { - var result10 = input.charAt(pos); - pos++; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result10 !== null) { - var result7 = [result8, result9, result10]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - if (result7 !== null) { - var result5 = []; - while (result7 !== null) { - result5.push(result7); - var savedPos1 = pos; - var savedPos3 = pos; - var savedReportMatchFailuresVar1 = reportMatchFailures; - reportMatchFailures = false; - var result12 = parse_rd(); - reportMatchFailures = savedReportMatchFailuresVar1; - if (result12 === null) { - var result8 = ''; - } else { - var result8 = null; - pos = savedPos3; - } - if (result8 !== null) { - var savedPos2 = pos; - var savedReportMatchFailuresVar0 = reportMatchFailures; - reportMatchFailures = false; - var result11 = parse_eol(); - reportMatchFailures = savedReportMatchFailuresVar0; - if (result11 === null) { - var result9 = ''; - } else { - var result9 = null; - pos = savedPos2; - } - if (result9 !== null) { - if (input.length > pos) { - var result10 = input.charAt(pos); - pos++; - } else { - var result10 = null; - if (reportMatchFailures) { - matchFailed('any character'); - } - } - if (result10 !== null) { - var result7 = [result8, result9, result10]; - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } else { - var result7 = null; - pos = savedPos1; - } - } - } else { - var result5 = null; - } - if (result5 !== null) { - var result6 = parse_rd(); - if (result6 !== null) { - var result2 = [result3, result4, result5, result6]; - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - } else { - var result2 = null; - pos = savedPos0; - } - if (result2 !== null) { - var result0 = result2; - } else { - var result1 = parse_reference(); - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_ld() { - var cacheKey = "ld" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 1) === "{") { - var result0 = "{"; - pos += 1; - } else { - var result0 = null; - if (reportMatchFailures) { - matchFailed("\"{\""); - } - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_rd() { - var cacheKey = "rd" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 1) === "}") { - var result0 = "}"; - pos += 1; - } else { - var result0 = null; - if (reportMatchFailures) { - matchFailed("\"}\""); - } - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_eol() { - var cacheKey = "eol" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos, 1) === "\n") { - var result5 = "\n"; - pos += 1; - } else { - var result5 = null; - if (reportMatchFailures) { - matchFailed("\"\\n\""); - } - } - if (result5 !== null) { - var result0 = result5; - } else { - if (input.substr(pos, 2) === "\r\n") { - var result4 = "\r\n"; - pos += 2; - } else { - var result4 = null; - if (reportMatchFailures) { - matchFailed("\"\\r\\n\""); - } - } - if (result4 !== null) { - var result0 = result4; - } else { - if (input.substr(pos, 1) === "\r") { - var result3 = "\r"; - pos += 1; - } else { - var result3 = null; - if (reportMatchFailures) { - matchFailed("\"\\r\""); - } - } - if (result3 !== null) { - var result0 = result3; - } else { - if (input.substr(pos, 1) === "\u2028") { - var result2 = "\u2028"; - pos += 1; - } else { - var result2 = null; - if (reportMatchFailures) { - matchFailed("\"\\u2028\""); - } - } - if (result2 !== null) { - var result0 = result2; - } else { - if (input.substr(pos, 1) === "\u2029") { - var result1 = "\u2029"; - pos += 1; - } else { - var result1 = null; - if (reportMatchFailures) { - matchFailed("\"\\u2029\""); - } - } - if (result1 !== null) { - var result0 = result1; - } else { - var result0 = null;; - }; - }; - }; - }; - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function parse_ws() { - var cacheKey = "ws" + '@' + pos; - var cachedResult = cache[cacheKey]; - if (cachedResult) { - pos = cachedResult.nextPos; - return cachedResult.result; - } - - - if (input.substr(pos).match(/^[ \xA0\uFEFF]/) !== null) { - var result0 = input.charAt(pos); - pos++; - } else { - var result0 = null; - if (reportMatchFailures) { - matchFailed("[ \\xA0\\uFEFF]"); - } - } - - - - cache[cacheKey] = { - nextPos: pos, - result: result0 - }; - return result0; - } - - function buildErrorMessage() { - function buildExpected(failuresExpected) { - failuresExpected.sort(); - - var lastFailure = null; - var failuresExpectedUnique = []; - for (var i = 0; i < failuresExpected.length; i++) { - if (failuresExpected[i] !== lastFailure) { - failuresExpectedUnique.push(failuresExpected[i]); - lastFailure = failuresExpected[i]; - } - } - - switch (failuresExpectedUnique.length) { - case 0: - return 'end of input'; - case 1: - return failuresExpectedUnique[0]; - default: - return failuresExpectedUnique.slice(0, failuresExpectedUnique.length - 1).join(', ') - + ' or ' - + failuresExpectedUnique[failuresExpectedUnique.length - 1]; - } - } - - var expected = buildExpected(rightmostMatchFailuresExpected); - var actualPos = Math.max(pos, rightmostMatchFailuresPos); - var actual = actualPos < input.length - ? quote(input.charAt(actualPos)) - : 'end of input'; - - return 'Expected ' + expected + ' but ' + actual + ' found.'; - } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < rightmostMatchFailuresPos; i++) { - var ch = input.charAt(i); - if (ch === '\n') { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === '\r' | ch === '\u2028' || ch === '\u2029') { - line++; - column = 1; - seenCR = true; - } else { - column++; - seenCR = false; - } - } - - return { line: line, column: column }; - } - - - - function wrap(node, ck) { - - node['text'] = input.substring(ck.split('@')[1], pos); - - return node; - - } - - - - var result = parse_body(); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostMatchFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostMatchFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostMatchFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var errorPosition = computeErrorPosition(); - throw new SyntaxError( - buildErrorMessage(), - errorPosition.line, - errorPosition.column - ); - } - - return result; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(message, line, column) { - this.name = 'SyntaxError'; - this.message = message; - this.line = line; - this.column = column; - }; - - result.SyntaxError.prototype = Error.prototype; - - return result; -})(); - -dust.parse = parser.parse; - -})(typeof exports !== 'undefined' ? exports : window.dust); \ No newline at end of file diff --git a/node_modules/dust/lib/server.js b/node_modules/dust/lib/server.js deleted file mode 100644 index 122bba2..0000000 --- a/node_modules/dust/lib/server.js +++ /dev/null @@ -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; -} diff --git a/node_modules/dust/nbproject/private/config.properties b/node_modules/dust/nbproject/private/config.properties deleted file mode 100644 index e69de29..0000000 diff --git a/node_modules/dust/nbproject/private/private.properties b/node_modules/dust/nbproject/private/private.properties deleted file mode 100644 index 34b8c3d..0000000 --- a/node_modules/dust/nbproject/private/private.properties +++ /dev/null @@ -1 +0,0 @@ -platform.active=Ruby diff --git a/node_modules/dust/nbproject/private/private.xml b/node_modules/dust/nbproject/private/private.xml deleted file mode 100644 index c1f155a..0000000 --- a/node_modules/dust/nbproject/private/private.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/node_modules/dust/nbproject/private/rake-d.txt b/node_modules/dust/nbproject/private/rake-d.txt deleted file mode 100644 index 57417cb..0000000 --- a/node_modules/dust/nbproject/private/rake-d.txt +++ /dev/null @@ -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 diff --git a/node_modules/dust/nbproject/project.properties b/node_modules/dust/nbproject/project.properties deleted file mode 100644 index 09c4186..0000000 --- a/node_modules/dust/nbproject/project.properties +++ /dev/null @@ -1,6 +0,0 @@ -javac.classpath= -main.file= -platform.active=Ruby -source.encoding=UTF-8 -src.lib.dir=lib -src.src.dir=src diff --git a/node_modules/dust/nbproject/project.xml b/node_modules/dust/nbproject/project.xml deleted file mode 100644 index 02c683b..0000000 --- a/node_modules/dust/nbproject/project.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - org.netbeans.modules.ruby.rubyproject - - - dust - - - - - - - - diff --git a/node_modules/dust/package.json b/node_modules/dust/package.json deleted file mode 100644 index 896ef26..0000000 --- a/node_modules/dust/package.json +++ /dev/null @@ -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" -} diff --git a/node_modules/dust/src/build.js b/node_modules/dust/src/build.js deleted file mode 100644 index 1ff1b7e..0000000 --- a/node_modules/dust/src/build.js +++ /dev/null @@ -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);" -); \ No newline at end of file diff --git a/node_modules/dust/src/dust.pegjs b/node_modules/dust/src/dust.pegjs deleted file mode 100644 index 6334b62..0000000 --- a/node_modules/dust/src/dust.pegjs +++ /dev/null @@ -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] \ No newline at end of file diff --git a/node_modules/dust/test/core.js b/node_modules/dust/test/core.js deleted file mode 100644 index c5335d8..0000000 --- a/node_modules/dust/test/core.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/node_modules/dust/test/examples.js b/node_modules/dust/test/examples.js deleted file mode 100644 index c3e76da..0000000 --- a/node_modules/dust/test/examples.js +++ /dev/null @@ -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: "", unsafe: "" }, - expected: "\n<script>alert('Goodbye!')</script>" - }, - { - name: "escape_pragma", - source: "{%esc:s}\n {unsafe}{~n}\n {%esc:h}\n {unsafe}\n {/esc}\n{/esc}", - context: { unsafe: "" }, - expected: "\n<script>alert('Goodbye!')</script>" - }, - { - 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" + - "
    {~n}\n" + - " {#tags}\n" + - " {~s}
  • {.}
  • {~n}\n" + - " {/tags}\n" + - "
\n" + - "{:else}\n" + - " No Tags!\n" + - "{/tags}\n" + - "{~n}\n" + - "{^likes}\n" + - " No Likes!\n" + - "{:else}\n" + - "
    {~n}\n" + - " {#likes}\n" + - " {~s}
  • {.}
  • {~n}\n" + - " {/likes}\n" + - "
\n" + - "{/likes}", - context: { tags: [], likes: ["moe", "larry", "curly", "shemp"] }, - expected: "No Tags!\n" + - "
    \n" + - "
  • moe
  • \n" + - "
  • larry
  • \n" + - "
  • curly
  • \n" + - "
  • shemp
  • \n" + - "
" - }, - { - 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("
    \n"); - for (var i=0; i") - .render(bodies.block, context.push(items[i])) - .write("\n"); - } - return chunk.write("
"); - } else if (bodies['else']) { - return chunk.render(bodies['else'], context); - } - return chunk; - }, - - projects: [ - {name: "Mayhem"}, - {name: "Flash"}, - {name: "Thunder"} - ] - }, - expected: "
    \n" + - "
  • Mayhem
  • \n" + - "
  • Flash
  • \n" + - "
  • Thunder
  • \n" + - "
" - }, - { - 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" + - "{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); \ No newline at end of file diff --git a/node_modules/dust/test/server.js b/node_modules/dust/test/server.js deleted file mode 100644 index 66b03ca..0000000 --- a/node_modules/dust/test/server.js +++ /dev/null @@ -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(); \ No newline at end of file diff --git a/node_modules/dust/test/uutest.js b/node_modules/dust/test/uutest.js deleted file mode 100644 index 79aa7a8..0000000 --- a/node_modules/dust/test/uutest.js +++ /dev/null @@ -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 - http://jsbeautifier.org/ - - Originally converted to javascript by Vital, - - You are free to use this in any way you want, in case you find this useful or working for you. - - Usage: - js_beautify(js_source_text); - js_beautify(js_source_text, options); - - The options are: - indent_size (default 4) — indentation size, - indent_char (default space) — character to indent with, - preserve_newlines (default true) — whether existing line breaks should be preserved, - indent_level (default 0) — initial indentation level, you probably won't need this ever, - - space_after_anon_function (default false) — if true, then space is added between "function ()" - (jslint is happy about this); if false, then the common "function()" output is used. - braces_on_own_line (default false) - ANSI / Allman brace style, each opening/closing brace gets its own line. - - e.g - - js_beautify(js_source_text, {indent_size: 1, indent_char: '\t'}); - - -*/ - - - -function js_beautify(js_source_text, options) { - - var input, output, token_text, last_type, last_text, last_last_text, last_word, flags, flag_store, indent_string; - var whitespace, wordchar, punct, parser_pos, line_starters, digits; - var prefix, token_type, do_block_just_closed; - var wanted_newline, just_added_newline, n_newlines; - - - // Some interpreters have unexpected results with foo = baz || bar; - options = options ? options : {}; - var opt_braces_on_own_line = options.braces_on_own_line ? options.braces_on_own_line : false; - var opt_indent_size = options.indent_size ? options.indent_size : 4; - var opt_indent_char = options.indent_char ? options.indent_char : ' '; - var opt_preserve_newlines = typeof options.preserve_newlines === 'undefined' ? true : options.preserve_newlines; - var opt_indent_level = options.indent_level ? options.indent_level : 0; // starting indentation - var opt_space_after_anon_function = options.space_after_anon_function === 'undefined' ? false : options.space_after_anon_function; - var opt_keep_array_indentation = typeof options.keep_array_indentation === 'undefined' ? false : options.keep_array_indentation; - - just_added_newline = false; - - // cache the source's length. - var input_length = js_source_text.length; - - function trim_output() { - while (output.length && (output[output.length - 1] === ' ' || output[output.length - 1] === indent_string)) { - output.pop(); - } - } - - function is_array(mode) { - return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]'; - } - - - function print_newline(ignore_repeated) { - - flags.eat_next_space = false; - if (opt_keep_array_indentation && is_array(flags.mode)) { - return; - } - - ignore_repeated = typeof ignore_repeated === 'undefined' ? true : ignore_repeated; - - flags.if_line = false; - trim_output(); - - if (!output.length) { - return; // no newline on start of file - } - - if (output[output.length - 1] !== "\n" || !ignore_repeated) { - just_added_newline = true; - output.push("\n"); - } - for (var i = 0; i < flags.indentation_level; i += 1) { - output.push(indent_string); - } - if (flags.var_line && flags.var_line_reindented) { - if (opt_indent_char === ' ') { - output.push(' '); // var_line always pushes 4 spaces, so that the variables would be one under another - } else { - output.push(indent_string); // skip space-stuffing, if indenting with a tab - } - } - } - - - - function print_single_space() { - if (flags.eat_next_space) { - flags.eat_next_space = false; - return; - } - var last_output = ' '; - if (output.length) { - last_output = output[output.length - 1]; - } - if (last_output !== ' ' && last_output !== '\n' && last_output !== indent_string) { // prevent occassional duplicate space - output.push(' '); - } - } - - - function print_token() { - just_added_newline = false; - flags.eat_next_space = false; - output.push(token_text); - } - - function indent() { - flags.indentation_level += 1; - } - - - function remove_indent() { - if (output.length && output[output.length - 1] === indent_string) { - output.pop(); - } - } - - function set_mode(mode) { - if (flags) { - flag_store.push(flags); - } - flags = { - previous_mode: flags ? flags.mode : 'BLOCK', - mode: mode, - var_line: false, - var_line_tainted: false, - var_line_reindented: false, - in_html_comment: false, - if_line: false, - in_case: false, - eat_next_space: false, - indentation_baseline: -1, - indentation_level: (flags ? flags.indentation_level + ((flags.var_line && flags.var_line_reindented) ? 1 : 0) : opt_indent_level) - }; - } - - function is_array(mode) { - return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]'; - } - - function is_expression(mode) { - return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]' || mode === '(EXPRESSION)'; - } - - function restore_mode() { - do_block_just_closed = flags.mode === 'DO_BLOCK'; - if (flag_store.length > 0) { - flags = flag_store.pop(); - } - } - - - function in_array(what, arr) { - for (var i = 0; i < arr.length; i += 1) { - if (arr[i] === what) { - return true; - } - } - return false; - } - - // Walk backwards from the colon to find a '?' (colon is part of a ternary op) - // or a '{' (colon is part of a class literal). Along the way, keep track of - // the blocks and expressions we pass so we only trigger on those chars in our - // own level, and keep track of the colons so we only trigger on the matching '?'. - - - function is_ternary_op() { - var level = 0, - colon_count = 0; - for (var i = output.length - 1; i >= 0; i--) { - switch (output[i]) { - case ':': - if (level === 0) { - colon_count++; - } - break; - case '?': - if (level === 0) { - if (colon_count === 0) { - return true; - } else { - colon_count--; - } - } - break; - case '{': - if (level === 0) { - return false; - } - level--; - break; - case '(': - case '[': - level--; - break; - case ')': - case ']': - case '}': - level++; - break; - } - } - } - - function get_next_token() { - n_newlines = 0; - - if (parser_pos >= input_length) { - return ['', 'TK_EOF']; - } - - wanted_newline = false; - - var c = input.charAt(parser_pos); - parser_pos += 1; - - - var keep_whitespace = opt_keep_array_indentation && is_array(flags.mode); - - if (keep_whitespace) { - - // - // slight mess to allow nice preservation of array indentation and reindent that correctly - // first time when we get to the arrays: - // var a = [ - // ....'something' - // we make note of whitespace_count = 4 into flags.indentation_baseline - // so we know that 4 whitespaces in original source match indent_level of reindented source - // - // and afterwards, when we get to - // 'something, - // .......'something else' - // we know that this should be indented to indent_level + (7 - indentation_baseline) spaces - // - var whitespace_count = 0; - - while (in_array(c, whitespace)) { - - if (c === "\n") { - trim_output(); - output.push("\n"); - just_added_newline = true; - whitespace_count = 0; - } else { - if (c === '\t') { - whitespace_count += 4; - } else { - whitespace_count += 1; - } - } - - if (parser_pos >= input_length) { - return ['', 'TK_EOF']; - } - - c = input.charAt(parser_pos); - parser_pos += 1; - - } - if (flags.indentation_baseline === -1) { - flags.indentation_baseline = whitespace_count; - } - - if (just_added_newline) { - var i; - for (i = 0; i < flags.indentation_level + 1; i += 1) { - output.push(indent_string); - } - if (flags.indentation_baseline !== -1) { - for (i = 0; i < whitespace_count - flags.indentation_baseline; i++) { - output.push(' '); - } - } - } - - } else { - while (in_array(c, whitespace)) { - - if (c === "\n") { - n_newlines += 1; - } - - - if (parser_pos >= input_length) { - return ['', 'TK_EOF']; - } - - c = input.charAt(parser_pos); - parser_pos += 1; - - } - - if (opt_preserve_newlines) { - if (n_newlines > 1) { - for (i = 0; i < n_newlines; i += 1) { - print_newline(i === 0); - just_added_newline = true; - } - } - } - wanted_newline = n_newlines > 0; - } - - - if (in_array(c, wordchar)) { - if (parser_pos < input_length) { - while (in_array(input.charAt(parser_pos), wordchar)) { - c += input.charAt(parser_pos); - parser_pos += 1; - if (parser_pos === input_length) { - break; - } - } - } - - // small and surprisingly unugly hack for 1E-10 representation - if (parser_pos !== input_length && c.match(/^[0-9]+[Ee]$/) && (input.charAt(parser_pos) === '-' || input.charAt(parser_pos) === '+')) { - - var sign = input.charAt(parser_pos); - parser_pos += 1; - - var t = get_next_token(parser_pos); - c += sign + t[0]; - return [c, 'TK_WORD']; - } - - if (c === 'in') { // hack for 'in' operator - return [c, 'TK_OPERATOR']; - } - if (wanted_newline && last_type !== 'TK_OPERATOR' && !flags.if_line && (opt_preserve_newlines || last_text !== 'var')) { - print_newline(); - } - return [c, 'TK_WORD']; - } - - if (c === '(' || c === '[') { - return [c, 'TK_START_EXPR']; - } - - if (c === ')' || c === ']') { - return [c, 'TK_END_EXPR']; - } - - if (c === '{') { - return [c, 'TK_START_BLOCK']; - } - - if (c === '}') { - return [c, 'TK_END_BLOCK']; - } - - if (c === ';') { - return [c, 'TK_SEMICOLON']; - } - - if (c === '/') { - var comment = ''; - // peek for comment /* ... */ - var inline_comment = true; - if (input.charAt(parser_pos) === '*') { - parser_pos += 1; - if (parser_pos < input_length) { - while (! (input.charAt(parser_pos) === '*' && input.charAt(parser_pos + 1) && input.charAt(parser_pos + 1) === '/') && parser_pos < input_length) { - c = input.charAt(parser_pos); - comment += c; - if (c === '\x0d' || c === '\x0a') { - inline_comment = false; - } - parser_pos += 1; - if (parser_pos >= input_length) { - break; - } - } - } - parser_pos += 2; - if (inline_comment) { - return ['/*' + comment + '*/', 'TK_INLINE_COMMENT']; - } else { - return ['/*' + comment + '*/', 'TK_BLOCK_COMMENT']; - } - } - // peek for comment // ... - if (input.charAt(parser_pos) === '/') { - comment = c; - while (input.charAt(parser_pos) !== "\x0d" && input.charAt(parser_pos) !== "\x0a") { - comment += input.charAt(parser_pos); - parser_pos += 1; - if (parser_pos >= input_length) { - break; - } - } - parser_pos += 1; - if (wanted_newline) { - print_newline(); - } - return [comment, 'TK_COMMENT']; - } - - } - - if (c === "'" || // string - c === '"' || // string - (c === '/' && ((last_type === 'TK_WORD' && in_array(last_text, ['return', 'do'])) || (last_type === 'TK_START_EXPR' || last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_OPERATOR' || last_type === 'TK_EQUALS' || last_type === 'TK_EOF' || last_type === 'TK_SEMICOLON')))) { // regexp - var sep = c; - var esc = false; - var resulting_string = c; - - if (parser_pos < input_length) { - if (sep === '/') { - // - // handle regexp separately... - // - var in_char_class = false; - while (esc || in_char_class || input.charAt(parser_pos) !== sep) { - resulting_string += input.charAt(parser_pos); - if (!esc) { - esc = input.charAt(parser_pos) === '\\'; - if (input.charAt(parser_pos) === '[') { - in_char_class = true; - } else if (input.charAt(parser_pos) === ']') { - in_char_class = false; - } - } else { - esc = false; - } - parser_pos += 1; - if (parser_pos >= input_length) { - // incomplete string/rexp when end-of-file reached. - // bail out with what had been received so far. - return [resulting_string, 'TK_STRING']; - } - } - - } else { - // - // and handle string also separately - // - while (esc || input.charAt(parser_pos) !== sep) { - resulting_string += input.charAt(parser_pos); - if (!esc) { - esc = input.charAt(parser_pos) === '\\'; - } else { - esc = false; - } - parser_pos += 1; - if (parser_pos >= input_length) { - // incomplete string/rexp when end-of-file reached. - // bail out with what had been received so far. - return [resulting_string, 'TK_STRING']; - } - } - } - - - - } - - parser_pos += 1; - - resulting_string += sep; - - if (sep === '/') { - // regexps may have modifiers /regexp/MOD , so fetch those, too - while (parser_pos < input_length && in_array(input.charAt(parser_pos), wordchar)) { - resulting_string += input.charAt(parser_pos); - parser_pos += 1; - } - } - return [resulting_string, 'TK_STRING']; - } - - if (c === '#') { - // Spidermonkey-specific sharp variables for circular references - // https://developer.mozilla.org/En/Sharp_variables_in_JavaScript - // http://mxr.mozilla.org/mozilla-central/source/js/src/jsscan.cpp around line 1935 - var sharp = '#'; - if (parser_pos < input_length && in_array(input.charAt(parser_pos), digits)) { - do { - c = input.charAt(parser_pos); - sharp += c; - parser_pos += 1; - } while (parser_pos < input_length && c !== '#' && c !== '='); - if (c === '#') { - // - } else if (input.charAt(parser_pos) === '[' && input.charAt(parser_pos + 1) === ']') { - sharp += '[]'; - parser_pos += 2; - } else if (input.charAt(parser_pos) === '{' && input.charAt(parser_pos + 1) === '}') { - sharp += '{}'; - parser_pos += 2; - } - return [sharp, 'TK_WORD']; - } - } - - if (c === '<' && input.substring(parser_pos - 1, parser_pos + 3) === '') { - flags.in_html_comment = false; - parser_pos += 2; - if (wanted_newline) { - print_newline(); - } - return ['-->', 'TK_COMMENT']; - } - - if (in_array(c, punct)) { - while (parser_pos < input_length && in_array(c + input.charAt(parser_pos), punct)) { - c += input.charAt(parser_pos); - parser_pos += 1; - if (parser_pos >= input_length) { - break; - } - } - - if (c === '=') { - return [c, 'TK_EQUALS']; - } else { - return [c, 'TK_OPERATOR']; - } - } - - return [c, 'TK_UNKNOWN']; - } - - //---------------------------------- - indent_string = ''; - while (opt_indent_size > 0) { - indent_string += opt_indent_char; - opt_indent_size -= 1; - } - - input = js_source_text; - - last_word = ''; // last 'TK_WORD' passed - last_type = 'TK_START_EXPR'; // last token type - last_text = ''; // last token text - last_last_text = ''; // pre-last token text - output = []; - - do_block_just_closed = false; - - whitespace = "\n\r\t ".split(''); - wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split(''); - digits = '0123456789'.split(''); - - punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'.split(' '); - - // words which should always start on new line. - line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(','); - - // states showing if we are currently in expression (i.e. "if" case) - 'EXPRESSION', or in usual block (like, procedure), 'BLOCK'. - // some formatting depends on that. - flag_store = []; - set_mode('BLOCK'); - - parser_pos = 0; - while (true) { - var t = get_next_token(parser_pos); - token_text = t[0]; - token_type = t[1]; - if (token_type === 'TK_EOF') { - break; - } - - switch (token_type) { - - case 'TK_START_EXPR': - - if (token_text === '[') { - - if (last_type === 'TK_WORD' || last_text === ')') { - // this is array index specifier, break immediately - // a[x], fn()[x] - if (in_array(last_text, line_starters)) { - print_single_space(); - } - set_mode('(EXPRESSION)'); - print_token(); - break; - } - - if (flags.mode === '[EXPRESSION]' || flags.mode === '[INDENTED-EXPRESSION]') { - if (last_last_text === ']' && last_text === ',') { - // ], [ goes to new line - if (flags.mode === '[EXPRESSION]') { - flags.mode = '[INDENTED-EXPRESSION]'; - if (!opt_keep_array_indentation) { - indent(); - } - } - set_mode('[EXPRESSION]'); - if (!opt_keep_array_indentation) { - print_newline(); - } - } else if (last_text === '[') { - if (flags.mode === '[EXPRESSION]') { - flags.mode = '[INDENTED-EXPRESSION]'; - if (!opt_keep_array_indentation) { - indent(); - } - } - set_mode('[EXPRESSION]'); - - if (!opt_keep_array_indentation) { - print_newline(); - } - } else { - set_mode('[EXPRESSION]'); - } - } else { - set_mode('[EXPRESSION]'); - } - - - - } else { - set_mode('(EXPRESSION)'); - } - - if (last_text === ';' || last_type === 'TK_START_BLOCK') { - print_newline(); - } else if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || last_text === '.') { - // do nothing on (( and )( and ][ and ]( and .( - } else if (last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') { - print_single_space(); - } else if (last_word === 'function') { - // function() vs function () - if (opt_space_after_anon_function) { - print_single_space(); - } - } else if (in_array(last_text, line_starters) || last_text === 'catch') { - print_single_space(); - } - print_token(); - - break; - - case 'TK_END_EXPR': - if (token_text === ']') { - if (opt_keep_array_indentation) { - if (last_text === '}') { - // trim_output(); - // print_newline(true); - remove_indent(); - print_token(); - restore_mode(); - break; - } - } else { - if (flags.mode === '[INDENTED-EXPRESSION]') { - if (last_text === ']') { - restore_mode(); - print_newline(); - print_token(); - break; - } - } - } - } - restore_mode(); - print_token(); - break; - - case 'TK_START_BLOCK': - - if (last_word === 'do') { - set_mode('DO_BLOCK'); - } else { - set_mode('BLOCK'); - } - if (opt_braces_on_own_line) { - if (last_type !== 'TK_OPERATOR') { - if (last_text == 'return') { - print_single_space(); - } else { - print_newline(true); - } - } - print_token(); - indent(); - } else { - if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') { - if (last_type === 'TK_START_BLOCK') { - print_newline(); - } else { - print_single_space(); - } - } else { - // if TK_OPERATOR or TK_START_EXPR - if (is_array(flags.previous_mode) && last_text === ',') { - print_newline(); // [a, b, c, { - } - } - indent(); - print_token(); - } - - break; - - case 'TK_END_BLOCK': - restore_mode(); - if (opt_braces_on_own_line) { - print_newline(); - print_token(); - } else { - if (last_type === 'TK_START_BLOCK') { - // nothing - if (just_added_newline) { - remove_indent(); - } else { - // {} - trim_output(); - } - } else { - print_newline(); - } - print_token(); - } - break; - - case 'TK_WORD': - - // no, it's not you. even I have problems understanding how this works - // and what does what. - if (do_block_just_closed) { - // do {} ## while () - print_single_space(); - print_token(); - print_single_space(); - do_block_just_closed = false; - break; - } - - if (token_text === 'function') { - if ((just_added_newline || last_text === ';') && last_text !== '{') { - // make sure there is a nice clean space of at least one blank line - // before a new function definition - n_newlines = just_added_newline ? n_newlines : 0; - - for (var i = 0; i < 2 - n_newlines; i++) { - print_newline(false); - } - - } - } - - if (token_text === 'case' || token_text === 'default') { - if (last_text === ':') { - // switch cases following one another - remove_indent(); - } else { - // case statement starts in the same line where switch - flags.indentation_level--; - print_newline(); - flags.indentation_level++; - } - print_token(); - flags.in_case = true; - break; - } - - prefix = 'NONE'; - - if (last_type === 'TK_END_BLOCK') { - if (!in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) { - prefix = 'NEWLINE'; - } else { - if (opt_braces_on_own_line) { - prefix = 'NEWLINE'; - } else { - prefix = 'SPACE'; - print_single_space(); - } - } - } else if (last_type === 'TK_SEMICOLON' && (flags.mode === 'BLOCK' || flags.mode === 'DO_BLOCK')) { - prefix = 'NEWLINE'; - } else if (last_type === 'TK_SEMICOLON' && is_expression(flags.mode)) { - prefix = 'SPACE'; - } else if (last_type === 'TK_STRING') { - prefix = 'NEWLINE'; - } else if (last_type === 'TK_WORD') { - prefix = 'SPACE'; - } else if (last_type === 'TK_START_BLOCK') { - prefix = 'NEWLINE'; - } else if (last_type === 'TK_END_EXPR') { - print_single_space(); - prefix = 'NEWLINE'; - } - - if (last_type !== 'TK_END_BLOCK' && in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) { - print_newline(); - } else if (in_array(token_text, line_starters) || prefix === 'NEWLINE') { - if (last_text === 'else') { - // no need to force newline on else break - print_single_space(); - } else if ((last_type === 'TK_START_EXPR' || last_text === '=' || last_text === ',') && token_text === 'function') { - // no need to force newline on 'function': (function - // DONOTHING - } else if (last_text === 'return' || last_text === 'throw') { - // no newline between 'return nnn' - print_single_space(); - } else if (last_type !== 'TK_END_EXPR') { - if ((last_type !== 'TK_START_EXPR' || token_text !== 'var') && last_text !== ':') { - // no need to force newline on 'var': for (var x = 0...) - if (token_text === 'if' && last_word === 'else' && last_text !== '{') { - // no newline for } else if { - print_single_space(); - } else { - print_newline(); - } - } - } else { - if (in_array(token_text, line_starters) && last_text !== ')') { - print_newline(); - } - } - } else if (is_array(flags.mode) && last_text === ',' && last_last_text === '}') { - print_newline(); // }, in lists get a newline treatment - } else if (prefix === 'SPACE') { - print_single_space(); - } - print_token(); - last_word = token_text; - - if (token_text === 'var') { - flags.var_line = true; - flags.var_line_reindented = false; - flags.var_line_tainted = false; - } - - if (token_text === 'if' || token_text === 'else') { - flags.if_line = true; - } - - break; - - case 'TK_SEMICOLON': - - print_token(); - flags.var_line = false; - flags.var_line_reindented = false; - break; - - case 'TK_STRING': - - if (last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_SEMICOLON') { - print_newline(); - } else if (last_type === 'TK_WORD') { - print_single_space(); - } - print_token(); - break; - - case 'TK_EQUALS': - if (flags.var_line) { - // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done - flags.var_line_tainted = true; - } - print_single_space(); - print_token(); - print_single_space(); - break; - - case 'TK_OPERATOR': - - var space_before = true; - var space_after = true; - - if (flags.var_line && token_text === ',' && (is_expression(flags.mode))) { - // do not break on comma, for(var a = 1, b = 2) - flags.var_line_tainted = false; - } - - if (flags.var_line) { - if (token_text === ',') { - if (flags.var_line_tainted) { - print_token(); - flags.var_line_reindented = true; - flags.var_line_tainted = false; - print_newline(); - break; - } else { - flags.var_line_tainted = false; - } - // } else if (token_text === ':') { - // hmm, when does this happen? tests don't catch this - // flags.var_line = false; - } - } - - if (last_text === 'return' || last_text === 'throw') { - // "return" had a special handling in TK_WORD. Now we need to return the favor - print_single_space(); - print_token(); - break; - } - - if (token_text === ':' && flags.in_case) { - print_token(); // colon really asks for separate treatment - print_newline(); - flags.in_case = false; - break; - } - - if (token_text === '::') { - // no spaces around exotic namespacing syntax operator - print_token(); - break; - } - - if (token_text === ',') { - if (flags.var_line) { - if (flags.var_line_tainted) { - print_token(); - print_newline(); - flags.var_line_tainted = false; - } else { - print_token(); - print_single_space(); - } - } else if (last_type === 'TK_END_BLOCK' && flags.mode !== "(EXPRESSION)") { - print_token(); - if (flags.mode === 'OBJECT' && last_text === '}') { - print_newline(); - } else { - print_single_space(); - } - } else { - if (flags.mode === 'OBJECT') { - print_token(); - print_newline(); - } else { - // EXPR or DO_BLOCK - print_token(); - print_single_space(); - } - } - break; - // } else if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS']) || in_array(last_text, line_starters) || in_array(last_text, ['==', '!=', '+=', '-=', '*=', '/=', '+', '-'])))) { - } else if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']) || in_array(last_text, line_starters)))) { - // unary operators (and binary +/- pretending to be unary) special cases - - space_before = false; - space_after = false; - - if (last_text === ';' && is_expression(flags.mode)) { - // for (;; ++i) - // ^^^ - space_before = true; - } - if (last_type === 'TK_WORD' && in_array(last_text, line_starters)) { - space_before = true; - } - - if (flags.mode === 'BLOCK' && (last_text === '{' || last_text === ';')) { - // { foo; --i } - // foo(); --bar; - print_newline(); - } - } else if (token_text === '.') { - // decimal digits or object.property - space_before = false; - - } else if (token_text === ':') { - if (!is_ternary_op()) { - flags.mode = 'OBJECT'; - space_before = false; - } - } - if (space_before) { - print_single_space(); - } - - print_token(); - - if (space_after) { - print_single_space(); - } - - if (token_text === '!') { - // flags.eat_next_space = true; - } - - break; - - case 'TK_BLOCK_COMMENT': - - var lines = token_text.split(/\x0a|\x0d\x0a/); - - if (/^\/\*\*/.test(token_text)) { - // javadoc: reformat and reindent - print_newline(); - output.push(lines[0]); - for (i = 1; i < lines.length; i++) { - print_newline(); - output.push(' '); - output.push(lines[i].replace(/^\s\s*|\s\s*$/, '')); - } - - } else { - // simple block comment: leave intact - if (lines.length > 1) { - // multiline comment block starts with a new line - print_newline(); - trim_output(); - } else { - // single-line /* comment */ stays where it is - print_single_space(); - } - for (i = 0; i < lines.length; i++) { - output.push(lines[i]); - output.push('\n'); - } - - } - print_newline(); - break; - - case 'TK_INLINE_COMMENT': - - print_single_space(); - print_token(); - if (is_expression(flags.mode)) { - print_single_space(); - } else { - print_newline(); - } - break; - - case 'TK_COMMENT': - - // print_newline(); - if (wanted_newline) { - print_newline(); - } else { - print_single_space(); - } - print_token(); - print_newline(); - break; - - case 'TK_UNKNOWN': - print_token(); - break; - } - - last_last_text = last_text; - last_type = token_type; - last_text = token_text; - } - - return output.join('').replace(/[\n ]+$/, ''); - -} - -// Add support for CommonJS. Just put this file somewhere on your require.paths -// and you will be able to `var js_beautify = require("beautify").js_beautify`. -if (typeof exports !== "undefined") - exports.js_beautify = js_beautify; \ No newline at end of file diff --git a/node_modules/dust/vendor/ecma.js b/node_modules/dust/vendor/ecma.js deleted file mode 100644 index 2b25803..0000000 --- a/node_modules/dust/vendor/ecma.js +++ /dev/null @@ -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+$/,""); - } -} \ No newline at end of file diff --git a/node_modules/dust/vendor/hijs.js b/node_modules/dust/vendor/hijs.js deleted file mode 100644 index 300ad9b..0000000 --- a/node_modules/dust/vendor/hijs.js +++ /dev/null @@ -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 -// 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 '' + escape(decode(value)) + ''; - }); -} - -function escape(str) { - return str.replace(//g, '>'); -} - -// 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); \ No newline at end of file diff --git a/node_modules/dust/vendor/jquery.min.js b/node_modules/dust/vendor/jquery.min.js deleted file mode 100644 index 7c24308..0000000 --- a/node_modules/dust/vendor/jquery.min.js +++ /dev/null @@ -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)[^>]*$|^#([\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
a"; -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="";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-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=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=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-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;j0){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":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=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 hl[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=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";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=""; -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="

";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="
";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=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},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-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=/"},F={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_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
","
"];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;b0||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;e0?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]===""&&!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=//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("
").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").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=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.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); diff --git a/node_modules/dust/vendor/jsdump.js b/node_modules/dust/vendor/jsdump.js deleted file mode 100644 index d7e67fa..0000000 --- a/node_modules/dust/vendor/jsdump.js +++ /dev/null @@ -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 ? '
' : '\n' : this.HTML ? ' ' : ' '; - }, - 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,' '); - 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 ? '<' : '<', - close = this.HTML ? '>' : '>'; - 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; -} \ No newline at end of file diff --git a/node_modules/dust/vendor/showdown.js b/node_modules/dust/vendor/showdown.js deleted file mode 100644 index 306dcb1..0000000 --- a/node_modules/dust/vendor/showdown.js +++ /dev/null @@ -1,1296 +0,0 @@ -// -// showdown.js -- A javascript port of Markdown. -// -// Copyright (c) 2007 John Fraser. -// -// Original Markdown Copyright (c) 2004-2005 John Gruber -// -// -// Redistributable under a BSD-style open source license. -// See license.txt for more information. -// -// The full source distribution is at: -// -// A A L -// T C A -// T K B -// -// -// - -// -// Wherever possible, Showdown is a straight, line-by-line port -// of the Perl version of Markdown. -// -// This is not a normal parser design; it's basically just a -// series of string substitutions. It's hard to read and -// maintain this way, but keeping Showdown close to the original -// design makes it easier to port new features. -// -// More importantly, Showdown behaves like markdown.pl in most -// edge cases. So web applications can do client-side preview -// in Javascript, and then build identical HTML on the server. -// -// This port needs the new RegExp functionality of ECMA 262, -// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers -// should do fine. Even with the new regular expression features, -// We do a lot of work to emulate Perl's regex functionality. -// The tricky changes in this file mostly have the "attacklab:" -// label. Major or self-explanatory changes don't. -// -// Smart diff tools like Araxis Merge will be able to match up -// this file with markdown.pl in a useful way. A little tweaking -// helps: in a copy of markdown.pl, replace "#" with "//" and -// replace "$text" with "text". Be sure to ignore whitespace -// and line endings. -// - - -// -// Showdown usage: -// -// var text = "Markdown *rocks*."; -// -// var converter = new Showdown.converter(); -// var html = converter.makeHtml(text); -// -// alert(html); -// -// Note: move the sample code to the bottom of this -// file before uncommenting it. -// - - -// -// Showdown namespace -// -var Showdown = {}; - -// -// converter -// -// Wraps all "globals" so that the only thing -// exposed is makeHtml(). -// -Showdown.converter = function() { - -// -// Globals: -// - -// Global hashes, used by various utility routines -var g_urls; -var g_titles; -var g_html_blocks; - -// Used to track when we're inside an ordered or unordered list -// (see _ProcessListItems() for details): -var g_list_level = 0; - - -this.makeHtml = function(text) { -// -// Main function. The order in which other subs are called here is -// essential. Link and image substitutions need to happen before -// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the -// and tags get encoded. -// - - // Clear the global hashes. If we don't clear these, you get conflicts - // from other articles when generating a page which contains more than - // one article (e.g. an index page that shows the N most recent - // articles): - g_urls = new Array(); - g_titles = new Array(); - g_html_blocks = new Array(); - - // attacklab: Replace ~ with ~T - // This lets us use tilde as an escape char to avoid md5 hashes - // The choice of character is arbitray; anything that isn't - // magic in Markdown will work. - text = text.replace(/~/g,"~T"); - - // attacklab: Replace $ with ~D - // RegExp interprets $ as a special character - // when it's in a replacement string - text = text.replace(/\$/g,"~D"); - - // Standardize line endings - text = text.replace(/\r\n/g,"\n"); // DOS to Unix - text = text.replace(/\r/g,"\n"); // Mac to Unix - - // Make sure text begins and ends with a couple of newlines: - text = "\n\n" + text + "\n\n"; - - // Convert all tabs to spaces. - text = _Detab(text); - - // Strip any lines consisting only of spaces and tabs. - // This makes subsequent regexen easier to write, because we can - // match consecutive blank lines with /\n+/ instead of something - // contorted like /[ \t]*\n+/ . - text = text.replace(/^[ \t]+$/mg,""); - - // Turn block-level HTML blocks into hash entries - text = _HashHTMLBlocks(text); - - // Strip link definitions, store in hashes. - text = _StripLinkDefinitions(text); - - text = _RunBlockGamut(text); - - text = _UnescapeSpecialChars(text); - - // attacklab: Restore dollar signs - text = text.replace(/~D/g,"$$"); - - // attacklab: Restore tildes - text = text.replace(/~T/g,"~"); - - return text; -} - - -var _StripLinkDefinitions = function(text) { -// -// Strips link definitions from text, stores the URLs and titles in -// hash references. -// - - // Link defs are in the form: ^[id]: url "optional title" - - /* - var text = text.replace(/ - ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1 - [ \t]* - \n? // maybe *one* newline - [ \t]* - ? // url = $2 - [ \t]* - \n? // maybe one newline - [ \t]* - (?: - (\n*) // any lines skipped = $3 attacklab: lookbehind removed - ["(] - (.+?) // title = $4 - [")] - [ \t]* - )? // title is optional - (?:\n+|$) - /gm, - function(){...}); - */ - var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm, - function (wholeMatch,m1,m2,m3,m4) { - m1 = m1.toLowerCase(); - g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive - if (m3) { - // Oops, found blank lines, so it's not a title. - // Put back the parenthetical statement we stole. - return m3+m4; - } else if (m4) { - g_titles[m1] = m4.replace(/"/g,"""); - } - - // Completely remove the definition from the text - return ""; - } - ); - - return text; -} - - -var _HashHTMLBlocks = function(text) { - // attacklab: Double up blank lines to reduce lookaround - text = text.replace(/\n/g,"\n\n"); - - // Hashify HTML blocks: - // We only want to do this for block-level HTML tags, such as headers, - // lists, and tables. That's because we still want to wrap

s around - // "paragraphs" that are wrapped in non-block-level tags, such as anchors, - // phrase emphasis, and spans. The list of tags we're looking for is - // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" - - // First, look for nested blocks, e.g.: - //

- //
- // tags for inner block must be indented. - //
- //
- // - // The outermost tags must start at the left margin for this to match, and - // the inner nested divs must be indented. - // We need to do this before the next, more liberal match, because the next - // match will start at the first `
` and stop at the first `
`. - - // attacklab: This regex can be expensive when it fails. - /* - var text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_a) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*?\n // any number of lines, minimally matching - // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement); - - // - // Now match more liberally, simply from `\n` to `\n` - // - - /* - var text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_b) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*? // any number of lines, minimally matching - .* // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement); - - // Special case just for
. It was easier to make a special case than - // to make the other regex more complicated. - - /* - text = text.replace(/ - ( // save in $1 - \n\n // Starting after a blank line - [ ]{0,3} - (<(hr) // start tag = $2 - \b // word break - ([^<>])*? // - \/?>) // the matching end tag - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement); - - // Special case for standalone HTML comments: - - /* - text = text.replace(/ - ( // save in $1 - \n\n // Starting after a blank line - [ ]{0,3} // attacklab: g_tab_width - 1 - - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,hashElement); - - // PHP and ASP-style processor instructions ( and <%...%>) - - /* - text = text.replace(/ - (?: - \n\n // Starting after a blank line - ) - ( // save in $1 - [ ]{0,3} // attacklab: g_tab_width - 1 - (?: - <([?%]) // $2 - [^\r]*? - \2> - ) - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement); - - // attacklab: Undo double lines (see comment at top of this function) - text = text.replace(/\n\n/g,"\n"); - return text; -} - -var hashElement = function(wholeMatch,m1) { - var blockText = m1; - - // Undo double lines - blockText = blockText.replace(/\n\n/g,"\n"); - blockText = blockText.replace(/^\n/,""); - - // strip trailing blank lines - blockText = blockText.replace(/\n+$/g,""); - - // Replace the element text with a marker ("~KxK" where x is its key) - blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n"; - - return blockText; -}; - -var _RunBlockGamut = function(text) { -// -// These are all the transformations that form block-level -// tags like paragraphs, headers, and list items. -// - text = _DoHeaders(text); - - // Do Horizontal Rules: - var key = hashBlock("
"); - text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key); - text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key); - text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key); - - text = _DoLists(text); - text = _DoCodeBlocks(text); - text = _DoBlockQuotes(text); - - // We already ran _HashHTMLBlocks() before, in Markdown(), but that - // was to escape raw HTML in the original Markdown source. This time, - // we're escaping the markup we've just created, so that we don't wrap - //

tags around block-level tags. - text = _HashHTMLBlocks(text); - text = _FormParagraphs(text); - - return text; -} - - -var _RunSpanGamut = function(text) { -// -// These are all the transformations that occur *within* block-level -// tags like paragraphs, headers, and list items. -// - - text = _DoCodeSpans(text); - text = _EscapeSpecialCharsWithinTagAttributes(text); - text = _EncodeBackslashEscapes(text); - - // Process anchor and image tags. Images must come first, - // because ![foo][f] looks like an anchor. - text = _DoImages(text); - text = _DoAnchors(text); - - // Make links out of things like `` - // Must come after _DoAnchors(), because you can use < and > - // delimiters in inline links like [this](). - text = _DoAutoLinks(text); - text = _EncodeAmpsAndAngles(text); - text = _DoItalicsAndBold(text); - - // Do hard breaks: - text = text.replace(/ +\n/g,"
\n"); - - return text; -} - -var _EscapeSpecialCharsWithinTagAttributes = function(text) { -// -// Within tags -- meaning between < and > -- encode [\ ` * _] so they -// don't conflict with their use in Markdown for code, italics and strong. -// - - // Build a regex to find HTML tags and comments. See Friedl's - // "Mastering Regular Expressions", 2nd Ed., pp. 200-201. - var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi; - - text = text.replace(regex, function(wholeMatch) { - var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`"); - tag = escapeCharacters(tag,"\\`*_"); - return tag; - }); - - return text; -} - -var _DoAnchors = function(text) { -// -// Turn Markdown link shortcuts into XHTML
tags. -// - // - // First, handle reference-style links: [link text] [id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[] // or anything else - )* - ) - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - )()()()() // pad remaining backreferences - /g,_DoAnchors_callback); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag); - - // - // Next, inline-style links: [link text](url "optional title") - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[\]] // or anything else - ) - ) - \] - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // href = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // Title = $7 - \6 // matching quote - [ \t]* // ignore any spaces/tabs between closing quote and ) - )? // title is optional - \) - ) - /g,writeAnchorTag); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag); - - // - // Last, handle reference-style shortcuts: [link text] - // These must come last in case you've also got [link test][1] - // or [link test](/foo) - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ([^\[\]]+) // link text = $2; can't contain '[' or ']' - \] - )()()()()() // pad rest of backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); - - return text; -} - -var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { - if (m7 == undefined) m7 = ""; - var whole_match = m1; - var link_text = m2; - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = link_text.toLowerCase().replace(/ ?\n/g," "); - } - url = "#"+link_id; - - if (g_urls[link_id] != undefined) { - url = g_urls[link_id]; - if (g_titles[link_id] != undefined) { - title = g_titles[link_id]; - } - } - else { - if (whole_match.search(/\(\s*\)$/m)>-1) { - // Special case for explicit empty url - url = ""; - } else { - return whole_match; - } - } - } - - url = escapeCharacters(url,"*_"); - var result = ""; - - return result; -} - - -var _DoImages = function(text) { -// -// Turn Markdown image shortcuts into tags. -// - - // - // First, handle reference-style labeled images: ![alt text][id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - )()()()() // pad rest of backreferences - /g,writeImageTag); - */ - text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag); - - // - // Next, handle inline images: ![alt text](url "optional title") - // Don't forget: encode * and _ - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - \s? // One optional whitespace character - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // src url = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // title = $7 - \6 // matching quote - [ \t]* - )? // title is optional - \) - ) - /g,writeImageTag); - */ - text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag); - - return text; -} - -var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { - var whole_match = m1; - var alt_text = m2; - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (!title) title = ""; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = alt_text.toLowerCase().replace(/ ?\n/g," "); - } - url = "#"+link_id; - - if (g_urls[link_id] != undefined) { - url = g_urls[link_id]; - if (g_titles[link_id] != undefined) { - title = g_titles[link_id]; - } - } - else { - return whole_match; - } - } - - alt_text = alt_text.replace(/"/g,"""); - url = escapeCharacters(url,"*_"); - var result = "\""" + _RunSpanGamut(m1) + "");}); - - text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, - function(matchFound,m1){return hashBlock("

" + _RunSpanGamut(m1) + "

");}); - - // atx-style headers: - // # Header 1 - // ## Header 2 - // ## Header 2 with closing hashes ## - // ... - // ###### Header 6 - // - - /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ - - text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, - function(wholeMatch,m1,m2) { - var h_level = m1.length; - return hashBlock("" + _RunSpanGamut(m2) + ""); - }); - - return text; -} - -// This declaration keeps Dojo compressor from outputting garbage: -var _ProcessListItems; - -var _DoLists = function(text) { -// -// Form HTML ordered (numbered) and unordered (bulleted) lists. -// - - // attacklab: add sentinel to hack around khtml/safari bug: - // http://bugs.webkit.org/show_bug.cgi?id=11231 - text += "~0"; - - // Re-usable pattern to match any entirel ul or ol list: - - /* - var whole_list = / - ( // $1 = whole list - ( // $2 - [ ]{0,3} // attacklab: g_tab_width - 1 - ([*+-]|\d+[.]) // $3 = first list item marker - [ \t]+ - ) - [^\r]+? - ( // $4 - ~0 // sentinel for workaround; should be $ - | - \n{2,} - (?=\S) - (?! // Negative lookahead for another list item marker - [ \t]* - (?:[*+-]|\d+[.])[ \t]+ - ) - ) - )/g - */ - var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; - - if (g_list_level) { - text = text.replace(whole_list,function(wholeMatch,m1,m2) { - var list = m1; - var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol"; - - // Turn double returns into triple returns, so that we can make a - // paragraph for the last item in a list, if necessary: - list = list.replace(/\n{2,}/g,"\n\n\n");; - var result = _ProcessListItems(list); - - // Trim any trailing whitespace, to put the closing `` - // up on the preceding line, to get it past the current stupid - // HTML block parser. This is a hack to work around the terrible - // hack that is the HTML block parser. - result = result.replace(/\s+$/,""); - result = "<"+list_type+">" + result + "\n"; - return result; - }); - } else { - whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g; - text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) { - var runup = m1; - var list = m2; - - var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol"; - // Turn double returns into triple returns, so that we can make a - // paragraph for the last item in a list, if necessary: - var list = list.replace(/\n{2,}/g,"\n\n\n");; - var result = _ProcessListItems(list); - result = runup + "<"+list_type+">\n" + result + "\n"; - return result; - }); - } - - // attacklab: strip sentinel - text = text.replace(/~0/,""); - - return text; -} - -_ProcessListItems = function(list_str) { -// -// Process the contents of a single ordered or unordered list, splitting it -// into individual list items. -// - // The $g_list_level global keeps track of when we're inside a list. - // Each time we enter a list, we increment it; when we leave a list, - // we decrement. If it's zero, we're not in a list anymore. - // - // We do this because when we're not inside a list, we want to treat - // something like this: - // - // I recommend upgrading to version - // 8. Oops, now this line is treated - // as a sub-list. - // - // As a single paragraph, despite the fact that the second line starts - // with a digit-period-space sequence. - // - // Whereas when we're inside a list (or sub-list), that line will be - // treated as the start of a sub-list. What a kludge, huh? This is - // an aspect of Markdown's syntax that's hard to parse perfectly - // without resorting to mind-reading. Perhaps the solution is to - // change the syntax rules such that sub-lists must start with a - // starting cardinal number; e.g. "1." or "a.". - - g_list_level++; - - // trim trailing blank lines: - list_str = list_str.replace(/\n{2,}$/,"\n"); - - // attacklab: add sentinel to emulate \z - list_str += "~0"; - - /* - list_str = list_str.replace(/ - (\n)? // leading line = $1 - (^[ \t]*) // leading whitespace = $2 - ([*+-]|\d+[.]) [ \t]+ // list marker = $3 - ([^\r]+? // list item text = $4 - (\n{1,2})) - (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+)) - /gm, function(){...}); - */ - list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm, - function(wholeMatch,m1,m2,m3,m4){ - var item = m4; - var leading_line = m1; - var leading_space = m2; - - if (leading_line || (item.search(/\n{2,}/)>-1)) { - item = _RunBlockGamut(_Outdent(item)); - } - else { - // Recursion for sub-lists: - item = _DoLists(_Outdent(item)); - item = item.replace(/\n$/,""); // chomp(item) - item = _RunSpanGamut(item); - } - - return "
  • " + item + "
  • \n"; - } - ); - - // attacklab: strip sentinel - list_str = list_str.replace(/~0/g,""); - - g_list_level--; - return list_str; -} - - -var _DoCodeBlocks = function(text) { -// -// Process Markdown `
    ` blocks.
    -//
    -
    -	/*
    -		text = text.replace(text,
    -			/(?:\n\n|^)
    -			(								// $1 = the code block -- one or more lines, starting with a space/tab
    -				(?:
    -					(?:[ ]{4}|\t)			// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
    -					.*\n+
    -				)+
    -			)
    -			(\n*[ ]{0,3}[^ \t\n]|(?=~0))	// attacklab: g_tab_width
    -		/g,function(){...});
    -	*/
    -
    -	// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
    -	text += "~0";
    -
    -	text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
    -		function(wholeMatch,m1,m2) {
    -			var codeblock = m1;
    -			var nextChar = m2;
    -
    -			codeblock = _EncodeCode( _Outdent(codeblock));
    -			codeblock = _Detab(codeblock);
    -			codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
    -			codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
    -
    -			codeblock = "
    " + codeblock + "\n
    "; - - return hashBlock(codeblock) + nextChar; - } - ); - - // attacklab: strip sentinel - text = text.replace(/~0/,""); - - return text; -} - -var hashBlock = function(text) { - text = text.replace(/(^\n+|\n+$)/g,""); - return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n"; -} - - -var _DoCodeSpans = function(text) { -// -// * Backtick quotes are used for spans. -// -// * You can use multiple backticks as the delimiters if you want to -// include literal backticks in the code span. So, this input: -// -// Just type ``foo `bar` baz`` at the prompt. -// -// Will translate to: -// -//

    Just type foo `bar` baz at the prompt.

    -// -// There's no arbitrary limit to the number of backticks you -// can use as delimters. If you need three consecutive backticks -// in your code, use four for delimiters, etc. -// -// * You can use spaces to get literal backticks at the edges: -// -// ... type `` `bar` `` ... -// -// Turns to: -// -// ... type `bar` ... -// - - /* - text = text.replace(/ - (^|[^\\]) // Character before opening ` can't be a backslash - (`+) // $2 = Opening run of ` - ( // $3 = The code block - [^\r]*? - [^`] // attacklab: work around lack of lookbehind - ) - \2 // Matching closer - (?!`) - /gm, function(){...}); - */ - - text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, - function(wholeMatch,m1,m2,m3,m4) { - var c = m3; - c = c.replace(/^([ \t]*)/g,""); // leading whitespace - c = c.replace(/[ \t]*$/g,""); // trailing whitespace - c = _EncodeCode(c); - return m1+""+c+""; - }); - - return text; -} - - -var _EncodeCode = function(text) { -// -// Encode/escape certain characters inside Markdown code runs. -// The point is that in code, these characters are literals, -// and lose their special Markdown meanings. -// - // Encode all ampersands; HTML entities are not - // entities within a Markdown code span. - text = text.replace(/&/g,"&"); - - // Do the angle bracket song and dance: - text = text.replace(//g,">"); - - // Now, escape characters that are magic in Markdown: - text = escapeCharacters(text,"\*_{}[]\\",false); - -// jj the line above breaks this: -//--- - -//* Item - -// 1. Subitem - -// special char: * -//--- - - return text; -} - - -var _DoItalicsAndBold = function(text) { - - // must go first: - text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, - "$2"); - - text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, - "$2"); - - return text; -} - - -var _DoBlockQuotes = function(text) { - - /* - text = text.replace(/ - ( // Wrap whole match in $1 - ( - ^[ \t]*>[ \t]? // '>' at the start of a line - .+\n // rest of the first line - (.+\n)* // subsequent consecutive lines - \n* // blanks - )+ - ) - /gm, function(){...}); - */ - - text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, - function(wholeMatch,m1) { - var bq = m1; - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting - - // attacklab: clean up hack - bq = bq.replace(/~0/g,""); - - bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines - bq = _RunBlockGamut(bq); // recurse - - bq = bq.replace(/(^|\n)/g,"$1 "); - // These leading spaces screw with
     content, so we need to fix that:
    -			bq = bq.replace(
    -					/(\s*
    [^\r]+?<\/pre>)/gm,
    -				function(wholeMatch,m1) {
    -					var pre = m1;
    -					// attacklab: hack around Konqueror 3.5.4 bug:
    -					pre = pre.replace(/^  /mg,"~0");
    -					pre = pre.replace(/~0/g,"");
    -					return pre;
    -				});
    -
    -			return hashBlock("
    \n" + bq + "\n
    "); - }); - return text; -} - - -var _FormParagraphs = function(text) { -// -// Params: -// $text - string to process with html

    tags -// - - // Strip leading and trailing lines: - text = text.replace(/^\n+/g,""); - text = text.replace(/\n+$/g,""); - - var grafs = text.split(/\n{2,}/g); - var grafsOut = new Array(); - - // - // Wrap

    tags. - // - var end = grafs.length; - for (var i=0; i= 0) { - grafsOut.push(str); - } - else if (str.search(/\S/) >= 0) { - str = _RunSpanGamut(str); - str = str.replace(/^([ \t]*)/g,"

    "); - str += "

    " - grafsOut.push(str); - } - - } - - // - // Unhashify HTML blocks - // - end = grafsOut.length; - for (var i=0; i= 0) { - var blockText = g_html_blocks[RegExp.$1]; - blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs - grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText); - } - } - - return grafsOut.join("\n\n"); -} - - -var _EncodeAmpsAndAngles = function(text) { -// Smart processing for ampersands and angle brackets that need to be encoded. - - // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: - // http://bumppo.net/projects/amputator/ - text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"); - - // Encode naked <'s - text = text.replace(/<(?![a-z\/?\$!])/gi,"<"); - - return text; -} - - -var _EncodeBackslashEscapes = function(text) { -// -// Parameter: String. -// Returns: The string, with after processing the following backslash -// escape sequences. -// - - // attacklab: The polite way to do this is with the new - // escapeCharacters() function: - // - // text = escapeCharacters(text,"\\",true); - // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); - // - // ...but we're sidestepping its use of the (slow) RegExp constructor - // as an optimization for Firefox. This function gets called a LOT. - - text = text.replace(/\\(\\)/g,escapeCharacters_callback); - text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback); - return text; -} - - -var _DoAutoLinks = function(text) { - - text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"
    $1"); - - // Email addresses: - - /* - text = text.replace(/ - < - (?:mailto:)? - ( - [-.\w]+ - \@ - [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ - ) - > - /gi, _DoAutoLinks_callback()); - */ - text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, - function(wholeMatch,m1) { - return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); - } - ); - - return text; -} - - -var _EncodeEmailAddress = function(addr) { -// -// Input: an email address, e.g. "foo@example.com" -// -// Output: the email address as a mailto link, with each character -// of the address encoded as either a decimal or hex entity, in -// the hopes of foiling most address harvesting spam bots. E.g.: -// -// foo -// @example.com -// -// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk -// mailing list: -// - - // attacklab: why can't javascript speak hex? - function char2hex(ch) { - var hexDigits = '0123456789ABCDEF'; - var dec = ch.charCodeAt(0); - return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15)); - } - - var encode = [ - function(ch){return "&#"+ch.charCodeAt(0)+";";}, - function(ch){return "&#x"+char2hex(ch)+";";}, - function(ch){return ch;} - ]; - - addr = "mailto:" + addr; - - addr = addr.replace(/./g, function(ch) { - if (ch == "@") { - // this *must* be encoded. I insist. - ch = encode[Math.floor(Math.random()*2)](ch); - } else if (ch !=":") { - // leave ':' alone (to spot mailto: later) - var r = Math.random(); - // roughly 10% raw, 45% hex, 45% dec - ch = ( - r > .9 ? encode[2](ch) : - r > .45 ? encode[1](ch) : - encode[0](ch) - ); - } - return ch; - }); - - addr = "" + addr + ""; - addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part - - return addr; -} - - -var _UnescapeSpecialChars = function(text) { -// -// Swap back in all the special characters we've hidden. -// - text = text.replace(/~E(\d+)E/g, - function(wholeMatch,m1) { - var charCodeToReplace = parseInt(m1); - return String.fromCharCode(charCodeToReplace); - } - ); - return text; -} - - -var _Outdent = function(text) { -// -// Remove one level of line-leading tabs or spaces -// - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width - - // attacklab: clean up hack - text = text.replace(/~0/g,"") - - return text; -} - -var _Detab = function(text) { -// attacklab: Detab's completely rewritten for speed. -// In perl we could fix it by anchoring the regexp with \G. -// In javascript we're less fortunate. - - // expand first n-1 tabs - text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width - - // replace the nth with two sentinels - text = text.replace(/\t/g,"~A~B"); - - // use the sentinel to anchor our regex so it doesn't explode - text = text.replace(/~B(.+?)~A/g, - function(wholeMatch,m1,m2) { - var leadingText = m1; - var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width - - // there *must* be a better way to do this: - for (var i=0; i + +## Getting Started +A quick tutorial for how to use Dust + +## Contributing +* Open https://github.com/linkedin/dustjs-helpers in a browser and fork it. Then clone your fork: + + git clone https://github.com//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 + + 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 + +## 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. \ No newline at end of file diff --git a/node_modules/dustjs-helpers/dist/LICENSE b/node_modules/dustjs-helpers/dist/LICENSE new file mode 100644 index 0000000..1c59043 --- /dev/null +++ b/node_modules/dustjs-helpers/dist/LICENSE @@ -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. \ No newline at end of file diff --git a/node_modules/dustjs-helpers/dist/dust-helpers.js b/node_modules/dustjs-helpers/dist/dust-helpers.js new file mode 100644 index 0000000..d4a0d24 --- /dev/null +++ b/node_modules/dustjs-helpers/dist/dust-helpers.js @@ -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); \ No newline at end of file diff --git a/node_modules/dustjs-helpers/dist/dust-helpers.min.js b/node_modules/dustjs-helpers/dist/dust-helpers.min.js new file mode 100644 index 0000000..c18717b --- /dev/null +++ b/node_modules/dustjs-helpers/dist/dust-helpers.min.js @@ -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&¶ms.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); \ No newline at end of file diff --git a/node_modules/dustjs-helpers/lib/dust-helpers.js b/node_modules/dustjs-helpers/lib/dust-helpers.js new file mode 100644 index 0000000..2b013e0 --- /dev/null +++ b/node_modules/dustjs-helpers/lib/dust-helpers.js @@ -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); \ No newline at end of file diff --git a/node_modules/dustjs-helpers/package.json b/node_modules/dustjs-helpers/package.json new file mode 100644 index 0000000..3eab0bb --- /dev/null +++ b/node_modules/dustjs-helpers/package.json @@ -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" +} diff --git a/node_modules/dustjs-linkedin/.npmignore b/node_modules/dustjs-linkedin/.npmignore new file mode 100644 index 0000000..932018c --- /dev/null +++ b/node_modules/dustjs-linkedin/.npmignore @@ -0,0 +1,11 @@ +.grunt +.jshintrc +.travis.yml +_SpecRunner.html +Gruntfile.js +benchmark +docs +src +tmp +test +archive diff --git a/node_modules/dustjs-linkedin/CHANGELOG.md b/node_modules/dustjs-linkedin/CHANGELOG.md new file mode 100644 index 0000000..34da26e --- /dev/null +++ b/node_modules/dustjs-linkedin/CHANGELOG.md @@ -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) \ No newline at end of file diff --git a/node_modules/dustjs-linkedin/LICENSE b/node_modules/dustjs-linkedin/LICENSE new file mode 100644 index 0000000..1c59043 --- /dev/null +++ b/node_modules/dustjs-linkedin/LICENSE @@ -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. \ No newline at end of file diff --git a/node_modules/dustjs-linkedin/README.md b/node_modules/dustjs-linkedin/README.md new file mode 100644 index 0000000..7cddf11 --- /dev/null +++ b/node_modules/dustjs-linkedin/README.md @@ -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 + +More info and + + +## More +Read more here: . + +For LinkedIn dust-helpers: . + +For LinkedIn secure-filters : . + + +## 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 diff --git a/node_modules/dustjs-linkedin/bin/dustc b/node_modules/dustjs-linkedin/bin/dustc new file mode 100755 index 0000000..b2f52e7 --- /dev/null +++ b/node_modules/dustjs-linkedin/bin/dustc @@ -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}=] {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); + }); +} diff --git a/node_modules/dustjs-linkedin/bower.json b/node_modules/dustjs-linkedin/bower.json new file mode 100644 index 0000000..aa6f0a1 --- /dev/null +++ b/node_modules/dustjs-linkedin/bower.json @@ -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" + ] +} diff --git a/node_modules/dustjs-linkedin/dist/LICENSE b/node_modules/dustjs-linkedin/dist/LICENSE new file mode 100644 index 0000000..1c59043 --- /dev/null +++ b/node_modules/dustjs-linkedin/dist/LICENSE @@ -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. \ No newline at end of file diff --git a/node_modules/dustjs-linkedin/dist/dust-core.js b/node_modules/dustjs-linkedin/dist/dust-core.js new file mode 100644 index 0000000..de84df7 --- /dev/null +++ b/node_modules/dustjs-linkedin/dist/dust-core.js @@ -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 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\"\']/), + AMP = /&/g, + LT = //g, + QUOT = /\"/g, + SQUOT = /\'/g; + + dust.escapeHtml = function(s) { + if (typeof s === 'string') { + if (!HCHARS.test(s)) { + return s; + } + return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(QUOT,'"').replace(SQUOT, '''); + } + 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;})()); diff --git a/node_modules/dustjs-linkedin/dist/dust-core.min.js b/node_modules/dustjs-linkedin/dist/dust-core.min.js new file mode 100644 index 0000000..0fe1509 --- /dev/null +++ b/node_modules/dustjs-linkedin/dist/dust-core.min.js @@ -0,0 +1,4 @@ +/*! Dust - Asynchronous Templating - v2.4.2 +* http://linkedin.github.io/dustjs/ +* Copyright (c) 2014 Aleksander Williams; Released under the MIT License */ +!function(root){function Context(a,b,c,d){this.stack=a,this.global=b,this.blocks=c,this.templateName=d}function Stack(a,b,c,d){this.tail=b,this.isObject=a&&"object"==typeof a,this.head=a,this.index=c,this.of=d}function Stub(a){this.head=new Chunk(this),this.callback=a,this.out=""}function Stream(){this.head=new Chunk(this)}function Chunk(a,b,c){this.root=a,this.next=b,this.data=[],this.flushable=!1,this.taps=c}function Tap(a,b){this.head=a,this.tail=b}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,root&&root.console&&root.console.log&&(loggerContext=root.console,originalLog=root.console.log),logger.log=loggerContext?function(){logger.log="function"==typeof originalLog?function(){originalLog.apply(loggerContext,arguments)}:function(){var a=Array.prototype.slice.apply(arguments).join(" ");originalLog(a)},logger.log.apply(this,arguments)}:function(){},dust.log=function(a,b){b=b||INFO,dust.debugLevel!==NONE&&dust.indexInArray(loggingLevels,b)>=dust.indexInArray(loggingLevels,dust.debugLevel)&&(dust.logQueue||(dust.logQueue=[]),dust.logQueue.push({message:a,type:b}),logger.log("[DUST "+b+"]: "+a))},dust.helpers={},dust.cache={},dust.register=function(a,b){a&&(dust.cache[a]=b)},dust.render=function(a,b,c){var d=new Stub(c).head;try{dust.load(a,d,Context.wrap(b,a)).end()}catch(e){d.setError(e)}},dust.stream=function(a,b){var c=new Stream,d=c.head;return dust.nextTick(function(){try{dust.load(a,c.head,Context.wrap(b,a)).end()}catch(e){d.setError(e)}}),c},dust.renderSource=function(a,b,c){return dust.compileFn(a)(b,c)},dust.compileFn=function(a,b){b=b||null;var c=dust.loadSource(dust.compile(a,b));return function(a,d){var e=d?new Stub(d):new Stream;return dust.nextTick(function(){"function"==typeof c?c(e.head,Context.wrap(a,b)).end():dust.log(new Error("Template ["+b+"] cannot be resolved to a Dust function"),ERROR)}),e}},dust.load=function(a,b,c){var d=dust.cache[a];return d?d(b,c):dust.onLoad?b.map(function(b){dust.onLoad(a,function(d,e){return d?b.setError(d):(dust.cache[a]||dust.loadSource(dust.compile(e,a)),void dust.cache[a](b,c).end())})}):b.setError(new Error("Template Not Found: "+a))},dust.loadSource=function(source,path){return eval(source)},dust.isArray=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},dust.indexInArray=function(a,b,c){if(c=+c||0,Array.prototype.indexOf)return a.indexOf(b,c);if(void 0===a||null===a)throw new TypeError('cannot call method "indexOf" of null');var d=a.length;for(1/0===Math.abs(c)&&(c=0),0>c&&(c+=d,0>c&&(c=0));d>c;c++)if(a[c]===b)return c;return-1},dust.nextTick=function(){return function(a){setTimeout(a,0)}}(),dust.isEmpty=function(a){return dust.isArray(a)&&!a.length?!0:0===a?!1:!a},dust.filter=function(a,b,c){if(c)for(var d=0,e=c.length;e>d;d++){var f=c[d];"s"===f?b=null:"function"==typeof dust.filters[f]?a=dust.filters[f](a):dust.log("Invalid filter ["+f+"]",WARN)}return b&&(a=dust.filters[b](a)),a},dust.filters={h:function(a){return dust.escapeHtml(a)},j:function(a){return dust.escapeJs(a)},u:encodeURI,uc:encodeURIComponent,js:function(a){return JSON?JSON.stringify(a):(dust.log("JSON is undefined. JSON stringify has not been used on ["+a+"]",WARN),a)},jp:function(a){return JSON?JSON.parse(a):(dust.log("JSON is undefined. JSON parse has not been used on ["+a+"]",WARN),a)}},dust.makeBase=function(a){return new Context(new Stack,a)},Context.wrap=function(a,b){return a instanceof Context?a:new Context(new Stack(a),{},null,b)},Context.prototype.get=function(a,b){return"string"==typeof a&&("."===a[0]&&(b=!0,a=a.substr(1)),a=a.split(".")),this._get(b,a)},Context.prototype._get=function(a,b){var c,d,e,f,g=this.stack,h=1;if(d=b[0],e=b.length,a&&0===e)f=g,g=g.head;else{if(a)g&&(g=g.head?g.head[d]:void 0);else{for(;g&&(!g.isObject||(f=g.head,c=g.head[d],void 0===c));)g=g.tail;g=void 0!==c?c:this.global?this.global[d]:void 0}for(;g&&e>h;)f=g,g=g[b[h]],h++}return"function"==typeof g?function(){try{return g.apply(f,arguments)}catch(a){throw dust.log(a,ERROR),a}}:(void 0===g&&dust.log("Cannot find the value for reference [{"+b.join(".")+"}] in template ["+this.getTemplateName()+"]"),g)},Context.prototype.getPath=function(a,b){return this._get(a,b)},Context.prototype.push=function(a,b,c){return new Context(new Stack(a,this.stack,b,c),this.global,this.blocks,this.getTemplateName())},Context.prototype.rebase=function(a){return new Context(new Stack(a),this.global,this.blocks,this.getTemplateName())},Context.prototype.current=function(){return this.stack.head},Context.prototype.getBlock=function(a){if("function"==typeof a){var b=new Chunk;a=a(b,this).data.join("")}var c=this.blocks;if(!c)return void dust.log("No blocks for context[{"+a+"}] in template ["+this.getTemplateName()+"]",DEBUG);for(var d,e=c.length;e--;)if(d=c[e][a])return d},Context.prototype.shiftBlocks=function(a){var b,c=this.blocks;return a?(b=c?c.concat([a]):[a],new Context(this.stack,this.global,b,this.getTemplateName())):this},Context.prototype.getTemplateName=function(){return this.templateName},Stub.prototype.flush=function(){for(var a=this.head;a;){if(!a.flushable)return a.error?(this.callback(a.error),dust.log("Chunk error ["+a.error+"] thrown. Ceasing to render this template.",WARN),void(this.flush=EMPTY_FUNC)):void 0;this.out+=a.data.join(""),a=a.next,this.head=a}this.callback(null,this.out)},Stream.prototype.flush=function(){for(var a=this.head;a;){if(!a.flushable)return a.error?(this.emit("error",a.error),dust.log("Chunk error ["+a.error+"] thrown. Ceasing to render this template.",WARN),void(this.flush=EMPTY_FUNC)):void 0;this.emit("data",a.data.join("")),a=a.next,this.head=a}this.emit("end")},Stream.prototype.emit=function(a,b){if(!this.events)return dust.log("No events to emit",INFO),!1;var c=this.events[a];if(!c)return dust.log("Event type ["+a+"] does not exist",WARN),!1;if("function"==typeof c)c(b);else if(dust.isArray(c))for(var d=c.slice(0),e=0,f=d.length;f>e;e++)d[e](b);else dust.log("Event Handler ["+c+"] is not of a type that is handled by emit",WARN)},Stream.prototype.on=function(a,b){return this.events||(this.events={}),this.events[a]?"function"==typeof this.events[a]?this.events[a]=[this.events[a],b]:this.events[a].push(b):(dust.log("Event type ["+a+"] does not exist. Using just the specified callback.",WARN),b?this.events[a]=b:dust.log("Callback for type ["+a+"] does not exist. Listener not registered.",WARN)),this},Stream.prototype.pipe=function(a){return this.on("data",function(b){try{a.write(b,"utf8")}catch(c){dust.log(c,ERROR)}}).on("end",function(){try{return a.end()}catch(b){dust.log(b,ERROR)}}).on("error",function(b){a.error(b)}),this},Chunk.prototype.write=function(a){var b=this.taps;return b&&(a=b.go(a)),this.data.push(a),this},Chunk.prototype.end=function(a){return a&&this.write(a),this.flushable=!0,this.root.flush(),this},Chunk.prototype.map=function(a){var b=new Chunk(this.root,this.next,this.taps),c=new Chunk(this.root,b,this.taps);this.next=c,this.flushable=!0;try{a(c)}catch(d){dust.log(d,ERROR),c.setError(d)}return b},Chunk.prototype.tap=function(a){var b=this.taps;return this.taps=b?b.push(a):new Tap(a),this},Chunk.prototype.untap=function(){return this.taps=this.taps.tail,this},Chunk.prototype.render=function(a,b){return a(this,b)},Chunk.prototype.reference=function(a,b,c,d){return"function"==typeof a&&(a=a.apply(b.current(),[this,b,null,{auto:c,filters:d}]),a instanceof Chunk)?a:dust.isEmpty(a)?this:this.write(dust.filter(a,c,d))},Chunk.prototype.section=function(a,b,c,d){if("function"==typeof a){try{a=a.apply(b.current(),[this,b,c,d])}catch(e){return dust.log(e,ERROR),this.setError(e)}if(a instanceof Chunk)return a}var f=c.block,g=c["else"];if(d&&(b=b.push(d)),dust.isArray(a)){if(f){var h=a.length,i=this;if(h>0){b.stack.head&&(b.stack.head.$len=h);for(var j=0;h>j;j++)b.stack.head&&(b.stack.head.$idx=j),i=f(i,b.push(a[j],j,h));return b.stack.head&&(b.stack.head.$idx=void 0,b.stack.head.$len=void 0),i}if(g)return g(this,b)}}else if(a===!0){if(f)return f(this,b)}else if(a||0===a){if(f)return f(this,b.push(a))}else if(g)return g(this,b);return dust.log("Not rendering section (#) block in template ["+b.getTemplateName()+"], because above key was not found",DEBUG),this},Chunk.prototype.exists=function(a,b,c){var d=c.block,e=c["else"];if(dust.isEmpty(a)){if(e)return e(this,b)}else if(d)return d(this,b);return dust.log("Not rendering exists (?) block in template ["+b.getTemplateName()+"], because above key was not found",DEBUG),this},Chunk.prototype.notexists=function(a,b,c){var d=c.block,e=c["else"];if(dust.isEmpty(a)){if(d)return d(this,b)}else if(e)return e(this,b);return dust.log("Not rendering not exists (^) block check in template ["+b.getTemplateName()+"], because above key was found",DEBUG),this},Chunk.prototype.block=function(a,b,c){var d=c.block;return a&&(d=a),d?d(this,b):this},Chunk.prototype.partial=function(a,b,c){var d;d=dust.makeBase(b.global),d.blocks=b.blocks,b.stack&&b.stack.tail&&(d.stack=b.stack.tail),c&&(d=d.push(c)),"string"==typeof a&&(d.templateName=a),d=d.push(b.stack.head);var e;return e="function"==typeof a?this.capture(a,d,function(a,b){d.templateName=d.templateName||a,dust.load(a,b,d).end()}):dust.load(a,this,d)},Chunk.prototype.helper=function(a,b,c,d){var e=this;if(!dust.helpers[a])return dust.log("Invalid helper ["+a+"]",WARN),e;try{return dust.helpers[a](e,b,c,d)}catch(f){return dust.log("Error in "+a+" helper: "+f,ERROR),e.setError(f)}},Chunk.prototype.capture=function(a,b,c){return this.map(function(d){var e=new Stub(function(a,b){a?d.setError(a):c(b,d)});a(e.head,b).end()})},Chunk.prototype.setError=function(a){return this.error=a,this.root.flush(),this},Tap.prototype.push=function(a){return new Tap(a,this)},Tap.prototype.go=function(a){for(var b=this;b;)a=b.head(a),b=b.tail;return a};var HCHARS=new RegExp(/[&<>\"\']/),AMP=/&/g,LT=//g,QUOT=/\"/g,SQUOT=/\'/g;dust.escapeHtml=function(a){return"string"==typeof a&&HCHARS.test(a)?a.replace(AMP,"&").replace(LT,"<").replace(GT,">").replace(QUOT,""").replace(SQUOT,"'"):a};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(a){return"string"==typeof a?a.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"):a},"object"==typeof exports?module.exports=dust:root.dust=dust}(function(){return this}()); \ No newline at end of file diff --git a/node_modules/dustjs-linkedin/dist/dust-full.js b/node_modules/dustjs-linkedin/dist/dust-full.js new file mode 100644 index 0000000..040a6cc --- /dev/null +++ b/node_modules/dustjs-linkedin/dist/dust-full.js @@ -0,0 +1,3953 @@ +/*! 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 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\"\']/), + AMP = /&/g, + LT = //g, + QUOT = /\"/g, + SQUOT = /\'/g; + + dust.escapeHtml = function(s) { + if (typeof s === 'string') { + if (!HCHARS.test(s)) { + return s; + } + return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(QUOT,'"').replace(SQUOT, '''); + } + 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;})()); + +(function(root, factory) { + if (typeof exports === 'object') { + // in Node, require this file if we want to use the parser as a standalone module + module.exports = factory(require('./dust')); + // @see server file for parser methods exposed in node + } else { + // in the browser, store the factory output if we want to use the parser directly + factory(root.dust); + } +}(this, function(dust) { + var parser = (function() { + /* + * Generated by PEG.js 0.8.0. + * + * http://pegjs.majda.cz/ + */ + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function SyntaxError(message, expected, found, offset, line, column) { + this.message = message; + this.expected = expected; + this.found = found; + this.offset = offset; + this.line = line; + this.column = column; + + this.name = "SyntaxError"; + } + + peg$subclass(SyntaxError, Error); + + function parse(input) { + var options = arguments.length > 1 ? arguments[1] : {}, + + peg$FAILED = {}, + + peg$startRuleFunctions = { start: peg$parsestart }, + peg$startRuleFunction = peg$parsestart, + + peg$c0 = [], + peg$c1 = function(p) { + return ["body"] + .concat(p) + .concat([['line', line()], ['col', column()]]); + }, + peg$c2 = { type: "other", description: "section" }, + peg$c3 = peg$FAILED, + peg$c4 = null, + peg$c5 = function(t, b, e, n) { + if( (!n) || (t[1].text !== n.text) ) { + error("Expected end tag for "+t[1].text+" but it was not found."); + } + return true; + }, + peg$c6 = void 0, + peg$c7 = function(t, b, e, n) { + e.push(["param", ["literal", "block"], b]); + t.push(e); + return t.concat([['line', line()], ['col', column()]]); + }, + peg$c8 = "/", + peg$c9 = { type: "literal", value: "/", description: "\"/\"" }, + peg$c10 = function(t) { + t.push(["bodies"]); + return t.concat([['line', line()], ['col', column()]]); + }, + peg$c11 = /^[#?\^<+@%]/, + peg$c12 = { type: "class", value: "[#?\\^<+@%]", description: "[#?\\^<+@%]" }, + peg$c13 = function(t, n, c, p) { return [t, n, c, p] }, + peg$c14 = { type: "other", description: "end tag" }, + peg$c15 = function(n) { return n }, + peg$c16 = ":", + peg$c17 = { type: "literal", value: ":", description: "\":\"" }, + peg$c18 = function(n) {return n}, + peg$c19 = function(n) { return n ? ["context", n] : ["context"] }, + peg$c20 = { type: "other", description: "params" }, + peg$c21 = "=", + peg$c22 = { type: "literal", value: "=", description: "\"=\"" }, + peg$c23 = function(k, v) {return ["param", ["literal", k], v]}, + peg$c24 = function(p) { return ["params"].concat(p) }, + peg$c25 = { type: "other", description: "bodies" }, + peg$c26 = function(p) { return ["bodies"].concat(p) }, + peg$c27 = { type: "other", description: "reference" }, + peg$c28 = function(n, f) { return ["reference", n, f].concat([['line', line()], ['col', column()]]) }, + peg$c29 = { type: "other", description: "partial" }, + peg$c30 = ">", + peg$c31 = { type: "literal", value: ">", description: "\">\"" }, + peg$c32 = "+", + peg$c33 = { type: "literal", value: "+", description: "\"+\"" }, + peg$c34 = function(k) {return ["literal", k]}, + peg$c35 = function(s, n, c, p) { + var key = (s === ">") ? "partial" : s; + return [key, n, c, p].concat([['line', line()], ['col', column()]]); + }, + peg$c36 = { type: "other", description: "filters" }, + peg$c37 = "|", + peg$c38 = { type: "literal", value: "|", description: "\"|\"" }, + peg$c39 = function(f) { return ["filters"].concat(f) }, + peg$c40 = { type: "other", description: "special" }, + peg$c41 = "~", + peg$c42 = { type: "literal", value: "~", description: "\"~\"" }, + peg$c43 = function(k) { return ["special", k].concat([['line', line()], ['col', column()]]) }, + peg$c44 = { type: "other", description: "identifier" }, + peg$c45 = function(p) { var arr = ["path"].concat(p); arr.text = p[1].join('.'); return arr; }, + peg$c46 = function(k) { var arr = ["key", k]; arr.text = k; return arr; }, + peg$c47 = { type: "other", description: "number" }, + peg$c48 = function(n) { return ['literal', n]; }, + peg$c49 = { type: "other", description: "float" }, + peg$c50 = ".", + peg$c51 = { type: "literal", value: ".", description: "\".\"" }, + peg$c52 = function(l, r) { return parseFloat(l + "." + r.join('')); }, + peg$c53 = { type: "other", description: "integer" }, + peg$c54 = /^[0-9]/, + peg$c55 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c56 = function(digits) { return parseInt(digits.join(""), 10); }, + peg$c57 = { type: "other", description: "path" }, + peg$c58 = function(k, d) { + d = d[0]; + if (k && d) { + d.unshift(k); + return [false, d].concat([['line', line()], ['col', column()]]); + } + return [true, d].concat([['line', line()], ['col', column()]]); + }, + peg$c59 = function(d) { + if (d.length > 0) { + return [true, d[0]].concat([['line', line()], ['col', column()]]); + } + return [true, []].concat([['line', line()], ['col', column()]]); + }, + peg$c60 = { type: "other", description: "key" }, + peg$c61 = /^[a-zA-Z_$]/, + peg$c62 = { type: "class", value: "[a-zA-Z_$]", description: "[a-zA-Z_$]" }, + peg$c63 = /^[0-9a-zA-Z_$\-]/, + peg$c64 = { type: "class", value: "[0-9a-zA-Z_$\\-]", description: "[0-9a-zA-Z_$\\-]" }, + peg$c65 = function(h, t) { return h + t.join('') }, + peg$c66 = { type: "other", description: "array" }, + peg$c67 = function(n) {return n.join('')}, + peg$c68 = function(a) {return a; }, + peg$c69 = function(i, nk) { if(nk) { nk.unshift(i); } else {nk = [i] } return nk; }, + peg$c70 = { type: "other", description: "array_part" }, + peg$c71 = function(k) {return k}, + peg$c72 = function(d, a) { if (a) { return d.concat(a); } else { return d; } }, + peg$c73 = { type: "other", description: "inline" }, + peg$c74 = "\"", + peg$c75 = { type: "literal", value: "\"", description: "\"\\\"\"" }, + peg$c76 = function() { return ["literal", ""].concat([['line', line()], ['col', column()]]) }, + peg$c77 = function(l) { return ["literal", l].concat([['line', line()], ['col', column()]]) }, + peg$c78 = function(p) { return ["body"].concat(p).concat([['line', line()], ['col', column()]]) }, + peg$c79 = function(l) { return ["buffer", l] }, + peg$c80 = { type: "other", description: "buffer" }, + peg$c81 = function(e, w) { return ["format", e, w.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c82 = { type: "any", description: "any character" }, + peg$c83 = function(c) {return c}, + peg$c84 = function(b) { return ["buffer", b.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c85 = { type: "other", description: "literal" }, + peg$c86 = /^[^"]/, + peg$c87 = { type: "class", value: "[^\"]", description: "[^\"]" }, + peg$c88 = function(b) { return b.join('') }, + peg$c89 = "\\\"", + peg$c90 = { type: "literal", value: "\\\"", description: "\"\\\\\\\"\"" }, + peg$c91 = function() { return '"' }, + peg$c92 = { type: "other", description: "raw" }, + peg$c93 = "{`", + peg$c94 = { type: "literal", value: "{`", description: "\"{`\"" }, + peg$c95 = "`}", + peg$c96 = { type: "literal", value: "`}", description: "\"`}\"" }, + peg$c97 = function(char) {return char}, + peg$c98 = function(rawText) { return ["raw", rawText.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c99 = { type: "other", description: "comment" }, + peg$c100 = "{!", + peg$c101 = { type: "literal", value: "{!", description: "\"{!\"" }, + peg$c102 = "!}", + peg$c103 = { type: "literal", value: "!}", description: "\"!}\"" }, + peg$c104 = function(c) { return ["comment", c.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c105 = /^[#?\^><+%:@\/~%]/, + peg$c106 = { type: "class", value: "[#?\\^><+%:@\\/~%]", description: "[#?\\^><+%:@\\/~%]" }, + peg$c107 = "{", + peg$c108 = { type: "literal", value: "{", description: "\"{\"" }, + peg$c109 = "}", + peg$c110 = { type: "literal", value: "}", description: "\"}\"" }, + peg$c111 = "[", + peg$c112 = { type: "literal", value: "[", description: "\"[\"" }, + peg$c113 = "]", + peg$c114 = { type: "literal", value: "]", description: "\"]\"" }, + peg$c115 = "\n", + peg$c116 = { type: "literal", value: "\n", description: "\"\\n\"" }, + peg$c117 = "\r\n", + peg$c118 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" }, + peg$c119 = "\r", + peg$c120 = { type: "literal", value: "\r", description: "\"\\r\"" }, + peg$c121 = "\u2028", + peg$c122 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" }, + peg$c123 = "\u2029", + peg$c124 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" }, + peg$c125 = /^[\t\x0B\f \xA0\uFEFF]/, + peg$c126 = { type: "class", value: "[\\t\\x0B\\f \\xA0\\uFEFF]", description: "[\\t\\x0B\\f \\xA0\\uFEFF]" }, + + peg$currPos = 0, + peg$reportedPos = 0, + peg$cachedPos = 0, + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, + peg$maxFailPos = 0, + peg$maxFailExpected = [], + peg$silentFails = 0, + + peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$reportedPos, peg$currPos); + } + + function offset() { + return peg$reportedPos; + } + + function line() { + return peg$computePosDetails(peg$reportedPos).line; + } + + function column() { + return peg$computePosDetails(peg$reportedPos).column; + } + + function expected(description) { + throw peg$buildException( + null, + [{ type: "other", description: description }], + peg$reportedPos + ); + } + + function error(message) { + throw peg$buildException(message, null, peg$reportedPos); + } + + function peg$computePosDetails(pos) { + function advance(details, startPos, endPos) { + var p, ch; + + for (p = startPos; p < endPos; p++) { + ch = input.charAt(p); + if (ch === "\n") { + if (!details.seenCR) { details.line++; } + details.column = 1; + details.seenCR = false; + } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { + details.line++; + details.column = 1; + details.seenCR = true; + } else { + details.column++; + details.seenCR = false; + } + } + } + + if (peg$cachedPos !== pos) { + if (peg$cachedPos > pos) { + peg$cachedPos = 0; + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; + } + advance(peg$cachedPosDetails, peg$cachedPos, pos); + peg$cachedPos = pos; + } + + return peg$cachedPosDetails; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildException(message, expected, pos) { + function cleanupExpected(expected) { + var i = 1; + + expected.sort(function(a, b) { + if (a.description < b.description) { + return -1; + } else if (a.description > b.description) { + return 1; + } else { + return 0; + } + }); + + while (i < expected.length) { + if (expected[i - 1] === expected[i]) { + expected.splice(i, 1); + } else { + i++; + } + } + } + + function buildMessage(expected, found) { + function stringEscape(s) { + function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } + + return s + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\x08/g, '\\b') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\f/g, '\\f') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) + .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) + .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); + } + + var expectedDescs = new Array(expected.length), + expectedDesc, foundDesc, i; + + for (i = 0; i < expected.length; i++) { + expectedDescs[i] = expected[i].description; + } + + expectedDesc = expected.length > 1 + ? expectedDescs.slice(0, -1).join(", ") + + " or " + + expectedDescs[expected.length - 1] + : expectedDescs[0]; + + foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; + + return "Expected " + expectedDesc + " but " + foundDesc + " found."; + } + + var posDetails = peg$computePosDetails(pos), + found = pos < input.length ? input.charAt(pos) : null; + + if (expected !== null) { + cleanupExpected(expected); + } + + return new SyntaxError( + message !== null ? message : buildMessage(expected, found), + expected, + found, + pos, + posDetails.line, + posDetails.column + ); + } + + function peg$parsestart() { + var s0; + + s0 = peg$parsebody(); + + return s0; + } + + function peg$parsebody() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + s2 = peg$parsepart(); + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parsepart(); + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c1(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsepart() { + var s0; + + s0 = peg$parseraw(); + if (s0 === peg$FAILED) { + s0 = peg$parsecomment(); + if (s0 === peg$FAILED) { + s0 = peg$parsesection(); + if (s0 === peg$FAILED) { + s0 = peg$parsepartial(); + if (s0 === peg$FAILED) { + s0 = peg$parsespecial(); + if (s0 === peg$FAILED) { + s0 = peg$parsereference(); + if (s0 === peg$FAILED) { + s0 = peg$parsebuffer(); + } + } + } + } + } + } + + return s0; + } + + function peg$parsesection() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsesec_tag_start(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parserd(); + if (s3 !== peg$FAILED) { + s4 = peg$parsebody(); + if (s4 !== peg$FAILED) { + s5 = peg$parsebodies(); + if (s5 !== peg$FAILED) { + s6 = peg$parseend_tag(); + if (s6 === peg$FAILED) { + s6 = peg$c4; + } + if (s6 !== peg$FAILED) { + peg$reportedPos = peg$currPos; + s7 = peg$c5(s1, s4, s5, s6); + if (s7) { + s7 = peg$c6; + } else { + s7 = peg$c3; + } + if (s7 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c7(s1, s4, s5, s6); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsesec_tag_start(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s3 = peg$c8; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parserd(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c10(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c2); } + } + + return s0; + } + + function peg$parsesec_tag_start() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (peg$c11.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c12); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parsews(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parseidentifier(); + if (s4 !== peg$FAILED) { + s5 = peg$parsecontext(); + if (s5 !== peg$FAILED) { + s6 = peg$parseparams(); + if (s6 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c13(s2, s4, s5, s6); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + + return s0; + } + + function peg$parseend_tag() { + var s0, s1, s2, s3, s4, s5, s6; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s2 = peg$c8; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parsews(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parseidentifier(); + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$parsews(); + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$parsews(); + } + if (s5 !== peg$FAILED) { + s6 = peg$parserd(); + if (s6 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c15(s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c14); } + } + + return s0; + } + + function peg$parsecontext() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s2 = peg$c16; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseidentifier(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s1; + s2 = peg$c18(s3); + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$c3; + } + } else { + peg$currPos = s1; + s1 = peg$c3; + } + if (s1 === peg$FAILED) { + s1 = peg$c4; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c19(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseparams() { + var s0, s1, s2, s3, s4, s5, s6; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = []; + s4 = peg$parsews(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + } else { + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s5 = peg$c21; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c22); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parsenumber(); + if (s6 === peg$FAILED) { + s6 = peg$parseidentifier(); + if (s6 === peg$FAILED) { + s6 = peg$parseinline(); + } + } + if (s6 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s4, s6); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = []; + s4 = peg$parsews(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + } else { + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s5 = peg$c21; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c22); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parsenumber(); + if (s6 === peg$FAILED) { + s6 = peg$parseidentifier(); + if (s6 === peg$FAILED) { + s6 = peg$parseinline(); + } + } + if (s6 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s4, s6); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c24(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c20); } + } + + return s0; + } + + function peg$parsebodies() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = peg$parseld(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c16; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parsekey(); + if (s5 !== peg$FAILED) { + s6 = peg$parserd(); + if (s6 !== peg$FAILED) { + s7 = peg$parsebody(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s5, s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = peg$parseld(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c16; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parsekey(); + if (s5 !== peg$FAILED) { + s6 = peg$parserd(); + if (s6 !== peg$FAILED) { + s7 = peg$parsebody(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s5, s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c26(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c25); } + } + + return s0; + } + + function peg$parsereference() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + s2 = peg$parseidentifier(); + if (s2 !== peg$FAILED) { + s3 = peg$parsefilters(); + if (s3 !== peg$FAILED) { + s4 = peg$parserd(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c28(s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c27); } + } + + return s0; + } + + function peg$parsepartial() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 62) { + s2 = peg$c30; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c31); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s2 = peg$c32; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c33); } + } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parsews(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parsekey(); + if (s5 !== peg$FAILED) { + peg$reportedPos = s4; + s5 = peg$c34(s5); + } + s4 = s5; + if (s4 === peg$FAILED) { + s4 = peg$parseinline(); + } + if (s4 !== peg$FAILED) { + s5 = peg$parsecontext(); + if (s5 !== peg$FAILED) { + s6 = peg$parseparams(); + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsews(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsews(); + } + if (s7 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s8 = peg$c8; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s8 !== peg$FAILED) { + s9 = peg$parserd(); + if (s9 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c35(s2, s4, s5, s6); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c29); } + } + + return s0; + } + + function peg$parsefilters() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 124) { + s3 = peg$c37; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c38); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c18(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 124) { + s3 = peg$c37; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c38); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c18(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c39(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c36); } + } + + return s0; + } + + function peg$parsespecial() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 126) { + s2 = peg$c41; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c42); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parsekey(); + if (s3 !== peg$FAILED) { + s4 = peg$parserd(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c43(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c40); } + } + + return s0; + } + + function peg$parseidentifier() { + var s0, s1; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsepath(); + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c45(s1); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsekey(); + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c46(s1); + } + s0 = s1; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c44); } + } + + return s0; + } + + function peg$parsenumber() { + var s0, s1; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsefloat(); + if (s1 === peg$FAILED) { + s1 = peg$parseinteger(); + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c48(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c47); } + } + + return s0; + } + + function peg$parsefloat() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseinteger(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c50; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parseinteger(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseinteger(); + } + } else { + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c52(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c49); } + } + + return s0; + } + + function peg$parseinteger() { + var s0, s1, s2; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c56(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c53); } + } + + return s0; + } + + function peg$parsepath() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsekey(); + if (s1 === peg$FAILED) { + s1 = peg$c4; + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + } + } else { + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c58(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s1 = peg$c50; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c59(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c57); } + } + + return s0; + } + + function peg$parsekey() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + if (peg$c61.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c62); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c63.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c64); } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c63.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c64); } + } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c65(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } + } + + return s0; + } + + function peg$parsearray() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$currPos; + s2 = peg$parselb(); + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + s4 = []; + if (peg$c54.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + if (peg$c54.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + } + } else { + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c67(s4); + } + s3 = s4; + if (s3 === peg$FAILED) { + s3 = peg$parseidentifier(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parserb(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s1; + s2 = peg$c68(s3); + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$c3; + } + } else { + peg$currPos = s1; + s1 = peg$c3; + } + } else { + peg$currPos = s1; + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + s2 = peg$parsearray_part(); + if (s2 === peg$FAILED) { + s2 = peg$c4; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c69(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + + return s0; + } + + function peg$parsearray_part() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c50; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c71(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c50; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c71(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + s2 = peg$parsearray(); + if (s2 === peg$FAILED) { + s2 = peg$c4; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c72(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c70); } + } + + return s0; + } + + function peg$parseinline() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c74; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s2 = peg$c74; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c76(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c74; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseliteral(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c74; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c77(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c74; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseinline_part(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseinline_part(); + } + } else { + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c74; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c78(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + + return s0; + } + + function peg$parseinline_part() { + var s0, s1; + + s0 = peg$parsespecial(); + if (s0 === peg$FAILED) { + s0 = peg$parsereference(); + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseliteral(); + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c79(s1); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parsebuffer() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseeol(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c81(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + peg$silentFails++; + s5 = peg$parseraw(); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsecomment(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = peg$c6; + } else { + peg$currPos = s5; + s5 = peg$c3; + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseeol(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = peg$c6; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + if (s6 !== peg$FAILED) { + if (input.length > peg$currPos) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + peg$silentFails++; + s5 = peg$parseraw(); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsecomment(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = peg$c6; + } else { + peg$currPos = s5; + s5 = peg$c3; + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseeol(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = peg$c6; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + if (s6 !== peg$FAILED) { + if (input.length > peg$currPos) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c84(s1); + } + s0 = s1; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c80); } + } + + return s0; + } + + function peg$parseliteral() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parseesc(); + if (s4 === peg$FAILED) { + if (peg$c86.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } + } + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parseesc(); + if (s4 === peg$FAILED) { + if (peg$c86.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } + } + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c88(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c85); } + } + + return s0; + } + + function peg$parseesc() { + var s0, s1; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c89) { + s1 = peg$c89; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c90); } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c91(); + } + s0 = s1; + + return s0; + } + + function peg$parseraw() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c93) { + s1 = peg$c93; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c94); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c95) { + s5 = peg$c95; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c97(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c95) { + s5 = peg$c95; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c97(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c95) { + s3 = peg$c95; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c98(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c92); } + } + + return s0; + } + + function peg$parsecomment() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c100) { + s1 = peg$c100; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c101); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c102) { + s5 = peg$c102; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c83(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c102) { + s5 = peg$c102; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c83(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c102) { + s3 = peg$c102; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c104(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + + return s0; + } + + function peg$parsetag() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + if (peg$c105.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c106); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsews(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsews(); + } + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parserd(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = peg$c6; + } else { + peg$currPos = s7; + s7 = peg$c3; + } + if (s7 !== peg$FAILED) { + s8 = peg$currPos; + peg$silentFails++; + s9 = peg$parseeol(); + peg$silentFails--; + if (s9 === peg$FAILED) { + s8 = peg$c6; + } else { + peg$currPos = s8; + s8 = peg$c3; + } + if (s8 !== peg$FAILED) { + if (input.length > peg$currPos) { + s9 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parserd(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = peg$c6; + } else { + peg$currPos = s7; + s7 = peg$c3; + } + if (s7 !== peg$FAILED) { + s8 = peg$currPos; + peg$silentFails++; + s9 = peg$parseeol(); + peg$silentFails--; + if (s9 === peg$FAILED) { + s8 = peg$c6; + } else { + peg$currPos = s8; + s8 = peg$c3; + } + if (s8 !== peg$FAILED) { + if (input.length > peg$currPos) { + s9 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } + } else { + s5 = peg$c3; + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsews(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsews(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parserd(); + if (s7 !== peg$FAILED) { + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$parsereference(); + } + + return s0; + } + + function peg$parseld() { + var s0; + + if (input.charCodeAt(peg$currPos) === 123) { + s0 = peg$c107; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c108); } + } + + return s0; + } + + function peg$parserd() { + var s0; + + if (input.charCodeAt(peg$currPos) === 125) { + s0 = peg$c109; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c110); } + } + + return s0; + } + + function peg$parselb() { + var s0; + + if (input.charCodeAt(peg$currPos) === 91) { + s0 = peg$c111; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c112); } + } + + return s0; + } + + function peg$parserb() { + var s0; + + if (input.charCodeAt(peg$currPos) === 93) { + s0 = peg$c113; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c114); } + } + + return s0; + } + + function peg$parseeol() { + var s0; + + if (input.charCodeAt(peg$currPos) === 10) { + s0 = peg$c115; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c116); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c117) { + s0 = peg$c117; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c118); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 13) { + s0 = peg$c119; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c120); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 8232) { + s0 = peg$c121; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c122); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 8233) { + s0 = peg$c123; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c124); } + } + } + } + } + } + + return s0; + } + + function peg$parsews() { + var s0; + + if (peg$c125.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c126); } + } + if (s0 === peg$FAILED) { + s0 = peg$parseeol(); + } + + return s0; + } + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail({ type: "end", description: "end of input" }); + } + + throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); + } + } + + return { + SyntaxError: SyntaxError, + parse: parse + }; +})(); + + // expose parser methods + dust.parse = parser.parse; + + return parser; +})); + + + +(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=dust.indexInArray(loggingLevels,dust.debugLevel)&&(dust.logQueue||(dust.logQueue=[]),dust.logQueue.push({message:a,type:b}),logger.log("[DUST "+b+"]: "+a))},dust.helpers={},dust.cache={},dust.register=function(a,b){a&&(dust.cache[a]=b)},dust.render=function(a,b,c){var d=new Stub(c).head;try{dust.load(a,d,Context.wrap(b,a)).end()}catch(e){d.setError(e)}},dust.stream=function(a,b){var c=new Stream,d=c.head;return dust.nextTick(function(){try{dust.load(a,c.head,Context.wrap(b,a)).end()}catch(e){d.setError(e)}}),c},dust.renderSource=function(a,b,c){return dust.compileFn(a)(b,c)},dust.compileFn=function(a,b){b=b||null;var c=dust.loadSource(dust.compile(a,b));return function(a,d){var e=d?new Stub(d):new Stream;return dust.nextTick(function(){"function"==typeof c?c(e.head,Context.wrap(a,b)).end():dust.log(new Error("Template ["+b+"] cannot be resolved to a Dust function"),ERROR)}),e}},dust.load=function(a,b,c){var d=dust.cache[a];return d?d(b,c):dust.onLoad?b.map(function(b){dust.onLoad(a,function(d,e){return d?b.setError(d):(dust.cache[a]||dust.loadSource(dust.compile(e,a)),void dust.cache[a](b,c).end())})}):b.setError(new Error("Template Not Found: "+a))},dust.loadSource=function(source,path){return eval(source)},dust.isArray=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},dust.indexInArray=function(a,b,c){if(c=+c||0,Array.prototype.indexOf)return a.indexOf(b,c);if(void 0===a||null===a)throw new TypeError('cannot call method "indexOf" of null');var d=a.length;for(1/0===Math.abs(c)&&(c=0),0>c&&(c+=d,0>c&&(c=0));d>c;c++)if(a[c]===b)return c;return-1},dust.nextTick=function(){return function(a){setTimeout(a,0)}}(),dust.isEmpty=function(a){return dust.isArray(a)&&!a.length?!0:0===a?!1:!a},dust.filter=function(a,b,c){if(c)for(var d=0,e=c.length;e>d;d++){var f=c[d];"s"===f?b=null:"function"==typeof dust.filters[f]?a=dust.filters[f](a):dust.log("Invalid filter ["+f+"]",WARN)}return b&&(a=dust.filters[b](a)),a},dust.filters={h:function(a){return dust.escapeHtml(a)},j:function(a){return dust.escapeJs(a)},u:encodeURI,uc:encodeURIComponent,js:function(a){return JSON?JSON.stringify(a):(dust.log("JSON is undefined. JSON stringify has not been used on ["+a+"]",WARN),a)},jp:function(a){return JSON?JSON.parse(a):(dust.log("JSON is undefined. JSON parse has not been used on ["+a+"]",WARN),a)}},dust.makeBase=function(a){return new Context(new Stack,a)},Context.wrap=function(a,b){return a instanceof Context?a:new Context(new Stack(a),{},null,b)},Context.prototype.get=function(a,b){return"string"==typeof a&&("."===a[0]&&(b=!0,a=a.substr(1)),a=a.split(".")),this._get(b,a)},Context.prototype._get=function(a,b){var c,d,e,f,g=this.stack,h=1;if(d=b[0],e=b.length,a&&0===e)f=g,g=g.head;else{if(a)g&&(g=g.head?g.head[d]:void 0);else{for(;g&&(!g.isObject||(f=g.head,c=g.head[d],void 0===c));)g=g.tail;g=void 0!==c?c:this.global?this.global[d]:void 0}for(;g&&e>h;)f=g,g=g[b[h]],h++}return"function"==typeof g?function(){try{return g.apply(f,arguments)}catch(a){throw dust.log(a,ERROR),a}}:(void 0===g&&dust.log("Cannot find the value for reference [{"+b.join(".")+"}] in template ["+this.getTemplateName()+"]"),g)},Context.prototype.getPath=function(a,b){return this._get(a,b)},Context.prototype.push=function(a,b,c){return new Context(new Stack(a,this.stack,b,c),this.global,this.blocks,this.getTemplateName())},Context.prototype.rebase=function(a){return new Context(new Stack(a),this.global,this.blocks,this.getTemplateName())},Context.prototype.current=function(){return this.stack.head},Context.prototype.getBlock=function(a){if("function"==typeof a){var b=new Chunk;a=a(b,this).data.join("")}var c=this.blocks;if(!c)return void dust.log("No blocks for context[{"+a+"}] in template ["+this.getTemplateName()+"]",DEBUG);for(var d,e=c.length;e--;)if(d=c[e][a])return d},Context.prototype.shiftBlocks=function(a){var b,c=this.blocks;return a?(b=c?c.concat([a]):[a],new Context(this.stack,this.global,b,this.getTemplateName())):this},Context.prototype.getTemplateName=function(){return this.templateName},Stub.prototype.flush=function(){for(var a=this.head;a;){if(!a.flushable)return a.error?(this.callback(a.error),dust.log("Chunk error ["+a.error+"] thrown. Ceasing to render this template.",WARN),void(this.flush=EMPTY_FUNC)):void 0;this.out+=a.data.join(""),a=a.next,this.head=a}this.callback(null,this.out)},Stream.prototype.flush=function(){for(var a=this.head;a;){if(!a.flushable)return a.error?(this.emit("error",a.error),dust.log("Chunk error ["+a.error+"] thrown. Ceasing to render this template.",WARN),void(this.flush=EMPTY_FUNC)):void 0;this.emit("data",a.data.join("")),a=a.next,this.head=a}this.emit("end")},Stream.prototype.emit=function(a,b){if(!this.events)return dust.log("No events to emit",INFO),!1;var c=this.events[a];if(!c)return dust.log("Event type ["+a+"] does not exist",WARN),!1;if("function"==typeof c)c(b);else if(dust.isArray(c))for(var d=c.slice(0),e=0,f=d.length;f>e;e++)d[e](b);else dust.log("Event Handler ["+c+"] is not of a type that is handled by emit",WARN)},Stream.prototype.on=function(a,b){return this.events||(this.events={}),this.events[a]?"function"==typeof this.events[a]?this.events[a]=[this.events[a],b]:this.events[a].push(b):(dust.log("Event type ["+a+"] does not exist. Using just the specified callback.",WARN),b?this.events[a]=b:dust.log("Callback for type ["+a+"] does not exist. Listener not registered.",WARN)),this},Stream.prototype.pipe=function(a){return this.on("data",function(b){try{a.write(b,"utf8")}catch(c){dust.log(c,ERROR)}}).on("end",function(){try{return a.end()}catch(b){dust.log(b,ERROR)}}).on("error",function(b){a.error(b)}),this},Chunk.prototype.write=function(a){var b=this.taps;return b&&(a=b.go(a)),this.data.push(a),this},Chunk.prototype.end=function(a){return a&&this.write(a),this.flushable=!0,this.root.flush(),this},Chunk.prototype.map=function(a){var b=new Chunk(this.root,this.next,this.taps),c=new Chunk(this.root,b,this.taps);this.next=c,this.flushable=!0;try{a(c)}catch(d){dust.log(d,ERROR),c.setError(d)}return b},Chunk.prototype.tap=function(a){var b=this.taps;return this.taps=b?b.push(a):new Tap(a),this},Chunk.prototype.untap=function(){return this.taps=this.taps.tail,this},Chunk.prototype.render=function(a,b){return a(this,b)},Chunk.prototype.reference=function(a,b,c,d){return"function"==typeof a&&(a=a.apply(b.current(),[this,b,null,{auto:c,filters:d}]),a instanceof Chunk)?a:dust.isEmpty(a)?this:this.write(dust.filter(a,c,d))},Chunk.prototype.section=function(a,b,c,d){if("function"==typeof a){try{a=a.apply(b.current(),[this,b,c,d])}catch(e){return dust.log(e,ERROR),this.setError(e)}if(a instanceof Chunk)return a}var f=c.block,g=c["else"];if(d&&(b=b.push(d)),dust.isArray(a)){if(f){var h=a.length,i=this;if(h>0){b.stack.head&&(b.stack.head.$len=h);for(var j=0;h>j;j++)b.stack.head&&(b.stack.head.$idx=j),i=f(i,b.push(a[j],j,h));return b.stack.head&&(b.stack.head.$idx=void 0,b.stack.head.$len=void 0),i}if(g)return g(this,b)}}else if(a===!0){if(f)return f(this,b)}else if(a||0===a){if(f)return f(this,b.push(a))}else if(g)return g(this,b);return dust.log("Not rendering section (#) block in template ["+b.getTemplateName()+"], because above key was not found",DEBUG),this},Chunk.prototype.exists=function(a,b,c){var d=c.block,e=c["else"];if(dust.isEmpty(a)){if(e)return e(this,b)}else if(d)return d(this,b);return dust.log("Not rendering exists (?) block in template ["+b.getTemplateName()+"], because above key was not found",DEBUG),this},Chunk.prototype.notexists=function(a,b,c){var d=c.block,e=c["else"];if(dust.isEmpty(a)){if(d)return d(this,b)}else if(e)return e(this,b);return dust.log("Not rendering not exists (^) block check in template ["+b.getTemplateName()+"], because above key was found",DEBUG),this},Chunk.prototype.block=function(a,b,c){var d=c.block;return a&&(d=a),d?d(this,b):this},Chunk.prototype.partial=function(a,b,c){var d;d=dust.makeBase(b.global),d.blocks=b.blocks,b.stack&&b.stack.tail&&(d.stack=b.stack.tail),c&&(d=d.push(c)),"string"==typeof a&&(d.templateName=a),d=d.push(b.stack.head);var e;return e="function"==typeof a?this.capture(a,d,function(a,b){d.templateName=d.templateName||a,dust.load(a,b,d).end()}):dust.load(a,this,d)},Chunk.prototype.helper=function(a,b,c,d){var e=this;if(!dust.helpers[a])return dust.log("Invalid helper ["+a+"]",WARN),e;try{return dust.helpers[a](e,b,c,d)}catch(f){return dust.log("Error in "+a+" helper: "+f,ERROR),e.setError(f)}},Chunk.prototype.capture=function(a,b,c){return this.map(function(d){var e=new Stub(function(a,b){a?d.setError(a):c(b,d)});a(e.head,b).end()})},Chunk.prototype.setError=function(a){return this.error=a,this.root.flush(),this},Tap.prototype.push=function(a){return new Tap(a,this)},Tap.prototype.go=function(a){for(var b=this;b;)a=b.head(a),b=b.tail;return a};var HCHARS=new RegExp(/[&<>\"\']/),AMP=/&/g,LT=//g,QUOT=/\"/g,SQUOT=/\'/g;dust.escapeHtml=function(a){return"string"==typeof a&&HCHARS.test(a)?a.replace(AMP,"&").replace(LT,"<").replace(GT,">").replace(QUOT,""").replace(SQUOT,"'"):a};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(a){return"string"==typeof a?a.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"):a},"object"==typeof exports?module.exports=dust:root.dust=dust}(function(){return this}()),function(a,b){"object"==typeof exports?module.exports=b(require("./dust")):b(a.dust)}(this,function(dust){var a=function(){function a(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}function b(a,b,c,d,e,f){this.message=a,this.expected=b,this.found=c,this.offset=d,this.line=e,this.column=f,this.name="SyntaxError"}function c(a){function c(){return f(nd).line}function d(){return f(nd).column}function e(a){throw h(a,null,nd)}function f(b){function c(b,c,d){var e,f;for(e=c;d>e;e++)f=a.charAt(e),"\n"===f?(b.seenCR||b.line++,b.column=1,b.seenCR=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(b.line++,b.column=1,b.seenCR=!0):(b.column++,b.seenCR=!1)}return od!==b&&(od>b&&(od=0,pd={line:1,column:1,seenCR:!1}),c(pd,od,b),od=b),pd}function g(a){qd>md||(md>qd&&(qd=md,rd=[]),rd.push(a))}function h(c,d,e){function g(a){var b=1;for(a.sort(function(a,b){return a.descriptionb.description?1:0});b1?g.slice(0,-1).join(", ")+" or "+g[a.length-1]:g[0],e=b?'"'+c(b)+'"':"end of input","Expected "+d+" but "+e+" found."}var i=f(e),j=emd?(j=a.charAt(md),md++):(j=T,0===sd&&g(vc)),j!==T?(nd=d,e=wc(j),d=e):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y),d!==T)for(;d!==T;)c.push(d),d=md,e=md,sd++,f=K(),sd--,f===T?e=_:(md=e,e=Y),e!==T?(f=md,sd++,h=I(),sd--,h===T?f=_:(md=f,f=Y),f!==T?(h=md,sd++,i=J(),sd--,i===T?h=_:(md=h,h=Y),h!==T?(i=md,sd++,j=P(),sd--,j===T?i=_:(md=i,i=Y),i!==T?(a.length>md?(j=a.charAt(md),md++):(j=T,0===sd&&g(vc)),j!==T?(nd=d,e=wc(j),d=e):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y);else c=Y;c!==T&&(nd=b,c=xc(c)),b=c}return sd--,b===T&&(c=T,0===sd&&g(tc)),b}function G(){var b,c,d,e,f;if(sd++,b=md,c=[],d=md,e=md,sd++,f=K(),sd--,f===T?e=_:(md=e,e=Y),e!==T?(f=H(),f===T&&(zc.test(a.charAt(md))?(f=a.charAt(md),md++):(f=T,0===sd&&g(Ac))),f!==T?(nd=d,e=wc(f),d=e):(md=d,d=Y)):(md=d,d=Y),d!==T)for(;d!==T;)c.push(d),d=md,e=md,sd++,f=K(),sd--,f===T?e=_:(md=e,e=Y),e!==T?(f=H(),f===T&&(zc.test(a.charAt(md))?(f=a.charAt(md),md++):(f=T,0===sd&&g(Ac))),f!==T?(nd=d,e=wc(f),d=e):(md=d,d=Y)):(md=d,d=Y);else c=Y;return c!==T&&(nd=b,c=Bc(c)),b=c,sd--,b===T&&(c=T,0===sd&&g(yc)),b}function H(){var b,c;return b=md,a.substr(md,2)===Cc?(c=Cc,md+=2):(c=T,0===sd&&g(Dc)),c!==T&&(nd=b,c=Ec()),b=c}function I(){var b,c,d,e,f,h;if(sd++,b=md,a.substr(md,2)===Gc?(c=Gc,md+=2):(c=T,0===sd&&g(Hc)),c!==T){for(d=[],e=md,f=md,sd++,a.substr(md,2)===Ic?(h=Ic,md+=2):(h=T,0===sd&&g(Jc)),sd--,h===T?f=_:(md=f,f=Y),f!==T?(a.length>md?(h=a.charAt(md),md++):(h=T,0===sd&&g(vc)),h!==T?(nd=e,f=Kc(h),e=f):(md=e,e=Y)):(md=e,e=Y);e!==T;)d.push(e),e=md,f=md,sd++,a.substr(md,2)===Ic?(h=Ic,md+=2):(h=T,0===sd&&g(Jc)),sd--,h===T?f=_:(md=f,f=Y),f!==T?(a.length>md?(h=a.charAt(md),md++):(h=T,0===sd&&g(vc)),h!==T?(nd=e,f=Kc(h),e=f):(md=e,e=Y)):(md=e,e=Y);d!==T?(a.substr(md,2)===Ic?(e=Ic,md+=2):(e=T,0===sd&&g(Jc)),e!==T?(nd=b,c=Lc(d),b=c):(md=b,b=Y)):(md=b,b=Y)}else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(Fc)),b}function J(){var b,c,d,e,f,h;if(sd++,b=md,a.substr(md,2)===Nc?(c=Nc,md+=2):(c=T,0===sd&&g(Oc)),c!==T){for(d=[],e=md,f=md,sd++,a.substr(md,2)===Pc?(h=Pc,md+=2):(h=T,0===sd&&g(Qc)),sd--,h===T?f=_:(md=f,f=Y),f!==T?(a.length>md?(h=a.charAt(md),md++):(h=T,0===sd&&g(vc)),h!==T?(nd=e,f=wc(h),e=f):(md=e,e=Y)):(md=e,e=Y);e!==T;)d.push(e),e=md,f=md,sd++,a.substr(md,2)===Pc?(h=Pc,md+=2):(h=T,0===sd&&g(Qc)),sd--,h===T?f=_:(md=f,f=Y),f!==T?(a.length>md?(h=a.charAt(md),md++):(h=T,0===sd&&g(vc)),h!==T?(nd=e,f=wc(h),e=f):(md=e,e=Y)):(md=e,e=Y);d!==T?(a.substr(md,2)===Pc?(e=Pc,md+=2):(e=T,0===sd&&g(Qc)),e!==T?(nd=b,c=Rc(d),b=c):(md=b,b=Y)):(md=b,b=Y)}else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(Mc)),b}function K(){var b,c,d,e,f,h,i,j,k,l;if(b=md,c=L(),c!==T){for(d=[],e=Q();e!==T;)d.push(e),e=Q();if(d!==T)if(Sc.test(a.charAt(md))?(e=a.charAt(md),md++):(e=T,0===sd&&g(Tc)),e!==T){for(f=[],h=Q();h!==T;)f.push(h),h=Q();if(f!==T){if(h=[],i=md,j=md,sd++,k=M(),sd--,k===T?j=_:(md=j,j=Y),j!==T?(k=md,sd++,l=P(),sd--,l===T?k=_:(md=k,k=Y),k!==T?(a.length>md?(l=a.charAt(md),md++):(l=T,0===sd&&g(vc)),l!==T?(j=[j,k,l],i=j):(md=i,i=Y)):(md=i,i=Y)):(md=i,i=Y),i!==T)for(;i!==T;)h.push(i),i=md,j=md,sd++,k=M(),sd--,k===T?j=_:(md=j,j=Y),j!==T?(k=md,sd++,l=P(),sd--,l===T?k=_:(md=k,k=Y),k!==T?(a.length>md?(l=a.charAt(md),md++):(l=T,0===sd&&g(vc)),l!==T?(j=[j,k,l],i=j):(md=i,i=Y)):(md=i,i=Y)):(md=i,i=Y);else h=Y;if(h!==T){for(i=[],j=Q();j!==T;)i.push(j),j=Q();i!==T?(j=M(),j!==T?(c=[c,d,e,f,h,i,j],b=c):(md=b,b=Y)):(md=b,b=Y)}else md=b,b=Y}else md=b,b=Y}else md=b,b=Y;else md=b,b=Y}else md=b,b=Y;return b===T&&(b=r()),b}function L(){var b;return 123===a.charCodeAt(md)?(b=Uc,md++):(b=T,0===sd&&g(Vc)),b}function M(){var b;return 125===a.charCodeAt(md)?(b=Wc,md++):(b=T,0===sd&&g(Xc)),b}function N(){var b;return 91===a.charCodeAt(md)?(b=Yc,md++):(b=T,0===sd&&g(Zc)),b}function O(){var b;return 93===a.charCodeAt(md)?(b=$c,md++):(b=T,0===sd&&g(_c)),b}function P(){var b;return 10===a.charCodeAt(md)?(b=ad,md++):(b=T,0===sd&&g(bd)),b===T&&(a.substr(md,2)===cd?(b=cd,md+=2):(b=T,0===sd&&g(dd)),b===T&&(13===a.charCodeAt(md)?(b=ed,md++):(b=T,0===sd&&g(fd)),b===T&&(8232===a.charCodeAt(md)?(b=gd,md++):(b=T,0===sd&&g(hd)),b===T&&(8233===a.charCodeAt(md)?(b=id,md++):(b=T,0===sd&&g(jd)))))),b}function Q(){var b;return kd.test(a.charAt(md))?(b=a.charAt(md),md++):(b=T,0===sd&&g(ld)),b===T&&(b=P()),b}var R,S=arguments.length>1?arguments[1]:{},T={},U={start:i},V=i,W=function(a){return["body"].concat(a).concat([["line",c()],["col",d()]])},X={type:"other",description:"section"},Y=T,Z=null,$=function(a,b,c,d){return d&&a[1].text===d.text||e("Expected end tag for "+a[1].text+" but it was not found."),!0},_=void 0,ab=function(a,b,e){return e.push(["param",["literal","block"],b]),a.push(e),a.concat([["line",c()],["col",d()]])},bb="/",cb={type:"literal",value:"/",description:'"/"'},db=function(a){return a.push(["bodies"]),a.concat([["line",c()],["col",d()]])},eb=/^[#?\^<+@%]/,fb={type:"class",value:"[#?\\^<+@%]",description:"[#?\\^<+@%]"},gb=function(a,b,c,d){return[a,b,c,d]},hb={type:"other",description:"end tag"},ib=function(a){return a},jb=":",kb={type:"literal",value:":",description:'":"'},lb=function(a){return a},mb=function(a){return a?["context",a]:["context"]},nb={type:"other",description:"params"},ob="=",pb={type:"literal",value:"=",description:'"="'},qb=function(a,b){return["param",["literal",a],b]},rb=function(a){return["params"].concat(a)},sb={type:"other",description:"bodies"},tb=function(a){return["bodies"].concat(a)},ub={type:"other",description:"reference"},vb=function(a,b){return["reference",a,b].concat([["line",c()],["col",d()]])},wb={type:"other",description:"partial"},xb=">",yb={type:"literal",value:">",description:'">"'},zb="+",Ab={type:"literal",value:"+",description:'"+"'},Bb=function(a){return["literal",a]},Cb=function(a,b,e,f){var g=">"===a?"partial":a;return[g,b,e,f].concat([["line",c()],["col",d()]])},Db={type:"other",description:"filters"},Eb="|",Fb={type:"literal",value:"|",description:'"|"'},Gb=function(a){return["filters"].concat(a)},Hb={type:"other",description:"special"},Ib="~",Jb={type:"literal",value:"~",description:'"~"'},Kb=function(a){return["special",a].concat([["line",c()],["col",d()]])},Lb={type:"other",description:"identifier"},Mb=function(a){var b=["path"].concat(a);return b.text=a[1].join("."),b},Nb=function(a){var b=["key",a];return b.text=a,b},Ob={type:"other",description:"number"},Pb=function(a){return["literal",a]},Qb={type:"other",description:"float"},Rb=".",Sb={type:"literal",value:".",description:'"."'},Tb=function(a,b){return parseFloat(a+"."+b.join(""))},Ub={type:"other",description:"integer"},Vb=/^[0-9]/,Wb={type:"class",value:"[0-9]",description:"[0-9]"},Xb=function(a){return parseInt(a.join(""),10)},Yb={type:"other",description:"path"},Zb=function(a,b){return b=b[0],a&&b?(b.unshift(a),[!1,b].concat([["line",c()],["col",d()]])):[!0,b].concat([["line",c()],["col",d()]])},$b=function(a){return a.length>0?[!0,a[0]].concat([["line",c()],["col",d()]]):[!0,[]].concat([["line",c()],["col",d()]])},_b={type:"other",description:"key"},ac=/^[a-zA-Z_$]/,bc={type:"class",value:"[a-zA-Z_$]",description:"[a-zA-Z_$]"},cc=/^[0-9a-zA-Z_$\-]/,dc={type:"class",value:"[0-9a-zA-Z_$\\-]",description:"[0-9a-zA-Z_$\\-]"},ec=function(a,b){return a+b.join("")},fc={type:"other",description:"array"},gc=function(a){return a.join("")},hc=function(a){return a},ic=function(a,b){return b?b.unshift(a):b=[a],b},jc={type:"other",description:"array_part"},kc=function(a){return a},lc=function(a,b){return b?a.concat(b):a},mc={type:"other",description:"inline"},nc='"',oc={type:"literal",value:'"',description:'"\\""'},pc=function(){return["literal",""].concat([["line",c()],["col",d()]])},qc=function(a){return["literal",a].concat([["line",c()],["col",d()]])},rc=function(a){return["body"].concat(a).concat([["line",c()],["col",d()]])},sc=function(a){return["buffer",a]},tc={type:"other",description:"buffer"},uc=function(a,b){return["format",a,b.join("")].concat([["line",c()],["col",d()]])},vc={type:"any",description:"any character"},wc=function(a){return a},xc=function(a){return["buffer",a.join("")].concat([["line",c()],["col",d()]])},yc={type:"other",description:"literal"},zc=/^[^"]/,Ac={type:"class",value:'[^"]',description:'[^"]'},Bc=function(a){return a.join("")},Cc='\\"',Dc={type:"literal",value:'\\"',description:'"\\\\\\""'},Ec=function(){return'"'},Fc={type:"other",description:"raw"},Gc="{`",Hc={type:"literal",value:"{`",description:'"{`"'},Ic="`}",Jc={type:"literal",value:"`}",description:'"`}"'},Kc=function(a){return a},Lc=function(a){return["raw",a.join("")].concat([["line",c()],["col",d()]])},Mc={type:"other",description:"comment"},Nc="{!",Oc={type:"literal",value:"{!",description:'"{!"'},Pc="!}",Qc={type:"literal",value:"!}",description:'"!}"'},Rc=function(a){return["comment",a.join("")].concat([["line",c()],["col",d()]])},Sc=/^[#?\^><+%:@\/~%]/,Tc={type:"class",value:"[#?\\^><+%:@\\/~%]",description:"[#?\\^><+%:@\\/~%]"},Uc="{",Vc={type:"literal",value:"{",description:'"{"'},Wc="}",Xc={type:"literal",value:"}",description:'"}"'},Yc="[",Zc={type:"literal",value:"[",description:'"["'},$c="]",_c={type:"literal",value:"]",description:'"]"'},ad="\n",bd={type:"literal",value:"\n",description:'"\\n"'},cd="\r\n",dd={type:"literal",value:"\r\n",description:'"\\r\\n"'},ed="\r",fd={type:"literal",value:"\r",description:'"\\r"'},gd="\u2028",hd={type:"literal",value:"\u2028",description:'"\\u2028"'},id="\u2029",jd={type:"literal",value:"\u2029",description:'"\\u2029"'},kd=/^[\t\x0B\f \xA0\uFEFF]/,ld={type:"class",value:"[\\t\\x0B\\f \\xA0\\uFEFF]",description:"[\\t\\x0B\\f \\xA0\\uFEFF]"},md=0,nd=0,od=0,pd={line:1,column:1,seenCR:!1},qd=0,rd=[],sd=0;if("startRule"in S){if(!(S.startRule in U))throw new Error("Can't start parsing from rule \""+S.startRule+'".');V=U[S.startRule]}if(R=V(),R!==T&&md===a.length)return R;throw R!==T&&mdc;c++)e=n.filterNode(a,b[c]),e&&f.push(e);return f}function d(a,b){var c,d,e,f,g=[b[0]];for(d=1,e=b.length;e>d;d++)f=n.filterNode(a,b[d]),f&&("buffer"===f[0]?c?c[1]+=f[1]:(c=f,g.push(f)):(c=null,g.push(f)));return g}function e(a,b){return["buffer",p[b[1]]]}function f(a,b){return b}function g(){}function h(a,b){var c={name:b,bodies:[],blocks:{},index:0,auto:"h"};return"(function(){dust.register("+(b?'"'+b+'"':"null")+","+n.compileNode(c,a)+");"+i(c)+j(c)+"return body_0;})();"}function i(a){var b,c=[],d=a.blocks;for(b in d)c.push('"'+b+'":'+d[b]);return c.length?(a.blocks="ctx=ctx.shiftBlocks(blocks);","var blocks={"+c.join(",")+"};"):a.blocks=""}function j(a){var b,c,d=[],e=a.bodies,f=a.blocks;for(b=0,c=e.length;c>b;b++)d[b]="function body_"+b+"(chk,ctx){"+f+"return chk"+e[b]+";}";return d.join("")}function k(a,b){var c,d,e="";for(c=1,d=b.length;d>c;c++)e+=n.compileNode(a,b[c]);return e}function l(a,b,c){return"."+c+"("+n.compileNode(a,b[1])+","+n.compileNode(a,b[2])+","+n.compileNode(a,b[4])+","+n.compileNode(a,b[3])+")"}function m(a){return a.replace(q,"\\\\").replace(r,'\\"').replace(s,"\\f").replace(t,"\\n").replace(u,"\\r").replace(v,"\\t")}var n={},o=dust.isArray;n.compile=function(c,d){if(!d&&null!==d)throw new Error("Template name parameter cannot be undefined when calling dust.compile");try{var e=b(a(c)); +return h(e,d)}catch(f){if(!f.line||!f.column)throw f;throw new SyntaxError(f.message+" At line : "+f.line+", column : "+f.column)}},n.filterNode=function(a,b){return n.optimizers[b[0]](a,b)},n.optimizers={body:d,buffer:f,special:e,format:g,reference:c,"#":c,"?":c,"^":c,"<":c,"+":c,"@":c,"%":c,partial:c,context:c,params:c,bodies:c,param:c,filters:f,key:f,path:f,literal:f,raw:f,comment:g,line:g,col:g},n.pragmas={esc:function(a,b,c){var d,e=a.auto;return b||(b="h"),a.auto="s"===b?"":b,d=k(a,c.block),a.auto=e,d}};var p={s:" ",n:"\n",r:"\r",lb:"{",rb:"}"};n.compileNode=function(a,b){return n.nodes[b[0]](a,b)},n.nodes={body:function(a,b){var c=a.index++,d="body_"+c;return a.bodies[c]=k(a,b),d},buffer:function(a,b){return".write("+w(b[1])+")"},format:function(a,b){return".write("+w(b[1]+b[2])+")"},reference:function(a,b){return".reference("+n.compileNode(a,b[1])+",ctx,"+n.compileNode(a,b[2])+")"},"#":function(a,b){return l(a,b,"section")},"?":function(a,b){return l(a,b,"exists")},"^":function(a,b){return l(a,b,"notexists")},"<":function(a,b){for(var c=b[4],d=1,e=c.length;e>d;d++){var f=c[d],g=f[1][1];if("block"===g)return a.blocks[b[1].text]=n.compileNode(a,f[2]),""}return""},"+":function(a,b){return"undefined"==typeof b[1].text&&"undefined"==typeof b[4]?".block(ctx.getBlock("+n.compileNode(a,b[1])+",chk, ctx),"+n.compileNode(a,b[2])+", {},"+n.compileNode(a,b[3])+")":".block(ctx.getBlock("+w(b[1].text)+"),"+n.compileNode(a,b[2])+","+n.compileNode(a,b[4])+","+n.compileNode(a,b[3])+")"},"@":function(a,b){return".helper("+w(b[1].text)+","+n.compileNode(a,b[2])+","+n.compileNode(a,b[4])+","+n.compileNode(a,b[3])+")"},"%":function(a,b){var c,d,e,f,g,h,i,j,k,l=b[1][1];if(!n.pragmas[l])return"";for(c=b[4],d={},j=1,k=c.length;k>j;j++)h=c[j],d[h[1][1]]=h[2];for(e=b[3],f={},j=1,k=e.length;k>j;j++)i=e[j],f[i[1][1]]=i[2][1];return g=b[2][1]?b[2][1].text:null,n.pragmas[l](a,g,d,f)},partial:function(a,b){return".partial("+n.compileNode(a,b[1])+","+n.compileNode(a,b[2])+","+n.compileNode(a,b[3])+")"},context:function(a,b){return b[1]?"ctx.rebase("+n.compileNode(a,b[1])+")":"ctx"},params:function(a,b){for(var c=[],d=1,e=b.length;e>d;d++)c.push(n.compileNode(a,b[d]));return c.length?"{"+c.join(",")+"}":"{}"},bodies:function(a,b){for(var c=[],d=1,e=b.length;e>d;d++)c.push(n.compileNode(a,b[d]));return"{"+c.join(",")+"}"},param:function(a,b){return n.compileNode(a,b[1])+":"+n.compileNode(a,b[2])},filters:function(a,b){for(var c=[],d=1,e=b.length;e>d;d++){var f=b[d];c.push('"'+f+'"')}return'"'+a.auto+'"'+(c.length?",["+c.join(",")+"]":"")},key:function(a,b){return'ctx.get(["'+b[1]+'"], false)'},path:function(a,b){for(var c=b[1],d=b[2],e=[],f=0,g=d.length;g>f;f++)e.push(o(d[f])?n.compileNode(a,d[f]):'"'+d[f]+'"');return"ctx.getPath("+c+", ["+e.join(",")+"])"},literal:function(a,b){return w(b[1])},raw:function(a,b){return".write("+w(b[1])+")"}};var q=/\\/g,r=/"/g,s=/\f/g,t=/\n/g,u=/\r/g,v=/\t/g,w="undefined"==typeof JSON?function(a){return'"'+m(a)+'"'}:JSON.stringify;return dust.compile=n.compile,dust.filterNode=n.filterNode,dust.optimizers=n.optimizers,dust.pragmas=n.pragmas,dust.compileNode=n.compileNode,dust.nodes=n.nodes,n}); \ No newline at end of file diff --git a/node_modules/dustjs-linkedin/lib/README.md b/node_modules/dustjs-linkedin/lib/README.md new file mode 100644 index 0000000..feb9f9d --- /dev/null +++ b/node_modules/dustjs-linkedin/lib/README.md @@ -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**. diff --git a/node_modules/dustjs-linkedin/lib/compiler.js b/node_modules/dustjs-linkedin/lib/compiler.js new file mode 100644 index 0000000..939d778 --- /dev/null +++ b/node_modules/dustjs-linkedin/lib/compiler.js @@ -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= 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 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\"\']/), + AMP = /&/g, + LT = //g, + QUOT = /\"/g, + SQUOT = /\'/g; + + dust.escapeHtml = function(s) { + if (typeof s === 'string') { + if (!HCHARS.test(s)) { + return s; + } + return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(QUOT,'"').replace(SQUOT, '''); + } + 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;})()); diff --git a/node_modules/dustjs-linkedin/lib/parser.js b/node_modules/dustjs-linkedin/lib/parser.js new file mode 100644 index 0000000..687387c --- /dev/null +++ b/node_modules/dustjs-linkedin/lib/parser.js @@ -0,0 +1,2664 @@ +/* Do not edit the parser directly. This is a generated file created using a build script and the PEG grammar. */ +(function(root, factory) { + if (typeof exports === 'object') { + // in Node, require this file if we want to use the parser as a standalone module + module.exports = factory(require('./dust')); + // @see server file for parser methods exposed in node + } else { + // in the browser, store the factory output if we want to use the parser directly + factory(root.dust); + } +}(this, function(dust) { + var parser = (function() { + /* + * Generated by PEG.js 0.8.0. + * + * http://pegjs.majda.cz/ + */ + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function SyntaxError(message, expected, found, offset, line, column) { + this.message = message; + this.expected = expected; + this.found = found; + this.offset = offset; + this.line = line; + this.column = column; + + this.name = "SyntaxError"; + } + + peg$subclass(SyntaxError, Error); + + function parse(input) { + var options = arguments.length > 1 ? arguments[1] : {}, + + peg$FAILED = {}, + + peg$startRuleFunctions = { start: peg$parsestart }, + peg$startRuleFunction = peg$parsestart, + + peg$c0 = [], + peg$c1 = function(p) { + return ["body"] + .concat(p) + .concat([['line', line()], ['col', column()]]); + }, + peg$c2 = { type: "other", description: "section" }, + peg$c3 = peg$FAILED, + peg$c4 = null, + peg$c5 = function(t, b, e, n) { + if( (!n) || (t[1].text !== n.text) ) { + error("Expected end tag for "+t[1].text+" but it was not found."); + } + return true; + }, + peg$c6 = void 0, + peg$c7 = function(t, b, e, n) { + e.push(["param", ["literal", "block"], b]); + t.push(e); + return t.concat([['line', line()], ['col', column()]]); + }, + peg$c8 = "/", + peg$c9 = { type: "literal", value: "/", description: "\"/\"" }, + peg$c10 = function(t) { + t.push(["bodies"]); + return t.concat([['line', line()], ['col', column()]]); + }, + peg$c11 = /^[#?\^<+@%]/, + peg$c12 = { type: "class", value: "[#?\\^<+@%]", description: "[#?\\^<+@%]" }, + peg$c13 = function(t, n, c, p) { return [t, n, c, p] }, + peg$c14 = { type: "other", description: "end tag" }, + peg$c15 = function(n) { return n }, + peg$c16 = ":", + peg$c17 = { type: "literal", value: ":", description: "\":\"" }, + peg$c18 = function(n) {return n}, + peg$c19 = function(n) { return n ? ["context", n] : ["context"] }, + peg$c20 = { type: "other", description: "params" }, + peg$c21 = "=", + peg$c22 = { type: "literal", value: "=", description: "\"=\"" }, + peg$c23 = function(k, v) {return ["param", ["literal", k], v]}, + peg$c24 = function(p) { return ["params"].concat(p) }, + peg$c25 = { type: "other", description: "bodies" }, + peg$c26 = function(p) { return ["bodies"].concat(p) }, + peg$c27 = { type: "other", description: "reference" }, + peg$c28 = function(n, f) { return ["reference", n, f].concat([['line', line()], ['col', column()]]) }, + peg$c29 = { type: "other", description: "partial" }, + peg$c30 = ">", + peg$c31 = { type: "literal", value: ">", description: "\">\"" }, + peg$c32 = "+", + peg$c33 = { type: "literal", value: "+", description: "\"+\"" }, + peg$c34 = function(k) {return ["literal", k]}, + peg$c35 = function(s, n, c, p) { + var key = (s === ">") ? "partial" : s; + return [key, n, c, p].concat([['line', line()], ['col', column()]]); + }, + peg$c36 = { type: "other", description: "filters" }, + peg$c37 = "|", + peg$c38 = { type: "literal", value: "|", description: "\"|\"" }, + peg$c39 = function(f) { return ["filters"].concat(f) }, + peg$c40 = { type: "other", description: "special" }, + peg$c41 = "~", + peg$c42 = { type: "literal", value: "~", description: "\"~\"" }, + peg$c43 = function(k) { return ["special", k].concat([['line', line()], ['col', column()]]) }, + peg$c44 = { type: "other", description: "identifier" }, + peg$c45 = function(p) { var arr = ["path"].concat(p); arr.text = p[1].join('.'); return arr; }, + peg$c46 = function(k) { var arr = ["key", k]; arr.text = k; return arr; }, + peg$c47 = { type: "other", description: "number" }, + peg$c48 = function(n) { return ['literal', n]; }, + peg$c49 = { type: "other", description: "float" }, + peg$c50 = ".", + peg$c51 = { type: "literal", value: ".", description: "\".\"" }, + peg$c52 = function(l, r) { return parseFloat(l + "." + r.join('')); }, + peg$c53 = { type: "other", description: "integer" }, + peg$c54 = /^[0-9]/, + peg$c55 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c56 = function(digits) { return parseInt(digits.join(""), 10); }, + peg$c57 = { type: "other", description: "path" }, + peg$c58 = function(k, d) { + d = d[0]; + if (k && d) { + d.unshift(k); + return [false, d].concat([['line', line()], ['col', column()]]); + } + return [true, d].concat([['line', line()], ['col', column()]]); + }, + peg$c59 = function(d) { + if (d.length > 0) { + return [true, d[0]].concat([['line', line()], ['col', column()]]); + } + return [true, []].concat([['line', line()], ['col', column()]]); + }, + peg$c60 = { type: "other", description: "key" }, + peg$c61 = /^[a-zA-Z_$]/, + peg$c62 = { type: "class", value: "[a-zA-Z_$]", description: "[a-zA-Z_$]" }, + peg$c63 = /^[0-9a-zA-Z_$\-]/, + peg$c64 = { type: "class", value: "[0-9a-zA-Z_$\\-]", description: "[0-9a-zA-Z_$\\-]" }, + peg$c65 = function(h, t) { return h + t.join('') }, + peg$c66 = { type: "other", description: "array" }, + peg$c67 = function(n) {return n.join('')}, + peg$c68 = function(a) {return a; }, + peg$c69 = function(i, nk) { if(nk) { nk.unshift(i); } else {nk = [i] } return nk; }, + peg$c70 = { type: "other", description: "array_part" }, + peg$c71 = function(k) {return k}, + peg$c72 = function(d, a) { if (a) { return d.concat(a); } else { return d; } }, + peg$c73 = { type: "other", description: "inline" }, + peg$c74 = "\"", + peg$c75 = { type: "literal", value: "\"", description: "\"\\\"\"" }, + peg$c76 = function() { return ["literal", ""].concat([['line', line()], ['col', column()]]) }, + peg$c77 = function(l) { return ["literal", l].concat([['line', line()], ['col', column()]]) }, + peg$c78 = function(p) { return ["body"].concat(p).concat([['line', line()], ['col', column()]]) }, + peg$c79 = function(l) { return ["buffer", l] }, + peg$c80 = { type: "other", description: "buffer" }, + peg$c81 = function(e, w) { return ["format", e, w.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c82 = { type: "any", description: "any character" }, + peg$c83 = function(c) {return c}, + peg$c84 = function(b) { return ["buffer", b.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c85 = { type: "other", description: "literal" }, + peg$c86 = /^[^"]/, + peg$c87 = { type: "class", value: "[^\"]", description: "[^\"]" }, + peg$c88 = function(b) { return b.join('') }, + peg$c89 = "\\\"", + peg$c90 = { type: "literal", value: "\\\"", description: "\"\\\\\\\"\"" }, + peg$c91 = function() { return '"' }, + peg$c92 = { type: "other", description: "raw" }, + peg$c93 = "{`", + peg$c94 = { type: "literal", value: "{`", description: "\"{`\"" }, + peg$c95 = "`}", + peg$c96 = { type: "literal", value: "`}", description: "\"`}\"" }, + peg$c97 = function(char) {return char}, + peg$c98 = function(rawText) { return ["raw", rawText.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c99 = { type: "other", description: "comment" }, + peg$c100 = "{!", + peg$c101 = { type: "literal", value: "{!", description: "\"{!\"" }, + peg$c102 = "!}", + peg$c103 = { type: "literal", value: "!}", description: "\"!}\"" }, + peg$c104 = function(c) { return ["comment", c.join('')].concat([['line', line()], ['col', column()]]) }, + peg$c105 = /^[#?\^><+%:@\/~%]/, + peg$c106 = { type: "class", value: "[#?\\^><+%:@\\/~%]", description: "[#?\\^><+%:@\\/~%]" }, + peg$c107 = "{", + peg$c108 = { type: "literal", value: "{", description: "\"{\"" }, + peg$c109 = "}", + peg$c110 = { type: "literal", value: "}", description: "\"}\"" }, + peg$c111 = "[", + peg$c112 = { type: "literal", value: "[", description: "\"[\"" }, + peg$c113 = "]", + peg$c114 = { type: "literal", value: "]", description: "\"]\"" }, + peg$c115 = "\n", + peg$c116 = { type: "literal", value: "\n", description: "\"\\n\"" }, + peg$c117 = "\r\n", + peg$c118 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" }, + peg$c119 = "\r", + peg$c120 = { type: "literal", value: "\r", description: "\"\\r\"" }, + peg$c121 = "\u2028", + peg$c122 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" }, + peg$c123 = "\u2029", + peg$c124 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" }, + peg$c125 = /^[\t\x0B\f \xA0\uFEFF]/, + peg$c126 = { type: "class", value: "[\\t\\x0B\\f \\xA0\\uFEFF]", description: "[\\t\\x0B\\f \\xA0\\uFEFF]" }, + + peg$currPos = 0, + peg$reportedPos = 0, + peg$cachedPos = 0, + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, + peg$maxFailPos = 0, + peg$maxFailExpected = [], + peg$silentFails = 0, + + peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$reportedPos, peg$currPos); + } + + function offset() { + return peg$reportedPos; + } + + function line() { + return peg$computePosDetails(peg$reportedPos).line; + } + + function column() { + return peg$computePosDetails(peg$reportedPos).column; + } + + function expected(description) { + throw peg$buildException( + null, + [{ type: "other", description: description }], + peg$reportedPos + ); + } + + function error(message) { + throw peg$buildException(message, null, peg$reportedPos); + } + + function peg$computePosDetails(pos) { + function advance(details, startPos, endPos) { + var p, ch; + + for (p = startPos; p < endPos; p++) { + ch = input.charAt(p); + if (ch === "\n") { + if (!details.seenCR) { details.line++; } + details.column = 1; + details.seenCR = false; + } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { + details.line++; + details.column = 1; + details.seenCR = true; + } else { + details.column++; + details.seenCR = false; + } + } + } + + if (peg$cachedPos !== pos) { + if (peg$cachedPos > pos) { + peg$cachedPos = 0; + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; + } + advance(peg$cachedPosDetails, peg$cachedPos, pos); + peg$cachedPos = pos; + } + + return peg$cachedPosDetails; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildException(message, expected, pos) { + function cleanupExpected(expected) { + var i = 1; + + expected.sort(function(a, b) { + if (a.description < b.description) { + return -1; + } else if (a.description > b.description) { + return 1; + } else { + return 0; + } + }); + + while (i < expected.length) { + if (expected[i - 1] === expected[i]) { + expected.splice(i, 1); + } else { + i++; + } + } + } + + function buildMessage(expected, found) { + function stringEscape(s) { + function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } + + return s + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\x08/g, '\\b') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\f/g, '\\f') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) + .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) + .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); + } + + var expectedDescs = new Array(expected.length), + expectedDesc, foundDesc, i; + + for (i = 0; i < expected.length; i++) { + expectedDescs[i] = expected[i].description; + } + + expectedDesc = expected.length > 1 + ? expectedDescs.slice(0, -1).join(", ") + + " or " + + expectedDescs[expected.length - 1] + : expectedDescs[0]; + + foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; + + return "Expected " + expectedDesc + " but " + foundDesc + " found."; + } + + var posDetails = peg$computePosDetails(pos), + found = pos < input.length ? input.charAt(pos) : null; + + if (expected !== null) { + cleanupExpected(expected); + } + + return new SyntaxError( + message !== null ? message : buildMessage(expected, found), + expected, + found, + pos, + posDetails.line, + posDetails.column + ); + } + + function peg$parsestart() { + var s0; + + s0 = peg$parsebody(); + + return s0; + } + + function peg$parsebody() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + s2 = peg$parsepart(); + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parsepart(); + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c1(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsepart() { + var s0; + + s0 = peg$parseraw(); + if (s0 === peg$FAILED) { + s0 = peg$parsecomment(); + if (s0 === peg$FAILED) { + s0 = peg$parsesection(); + if (s0 === peg$FAILED) { + s0 = peg$parsepartial(); + if (s0 === peg$FAILED) { + s0 = peg$parsespecial(); + if (s0 === peg$FAILED) { + s0 = peg$parsereference(); + if (s0 === peg$FAILED) { + s0 = peg$parsebuffer(); + } + } + } + } + } + } + + return s0; + } + + function peg$parsesection() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsesec_tag_start(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parserd(); + if (s3 !== peg$FAILED) { + s4 = peg$parsebody(); + if (s4 !== peg$FAILED) { + s5 = peg$parsebodies(); + if (s5 !== peg$FAILED) { + s6 = peg$parseend_tag(); + if (s6 === peg$FAILED) { + s6 = peg$c4; + } + if (s6 !== peg$FAILED) { + peg$reportedPos = peg$currPos; + s7 = peg$c5(s1, s4, s5, s6); + if (s7) { + s7 = peg$c6; + } else { + s7 = peg$c3; + } + if (s7 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c7(s1, s4, s5, s6); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsesec_tag_start(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s3 = peg$c8; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parserd(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c10(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c2); } + } + + return s0; + } + + function peg$parsesec_tag_start() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (peg$c11.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c12); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parsews(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parseidentifier(); + if (s4 !== peg$FAILED) { + s5 = peg$parsecontext(); + if (s5 !== peg$FAILED) { + s6 = peg$parseparams(); + if (s6 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c13(s2, s4, s5, s6); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + + return s0; + } + + function peg$parseend_tag() { + var s0, s1, s2, s3, s4, s5, s6; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s2 = peg$c8; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parsews(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parseidentifier(); + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$parsews(); + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$parsews(); + } + if (s5 !== peg$FAILED) { + s6 = peg$parserd(); + if (s6 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c15(s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c14); } + } + + return s0; + } + + function peg$parsecontext() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s2 = peg$c16; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseidentifier(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s1; + s2 = peg$c18(s3); + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$c3; + } + } else { + peg$currPos = s1; + s1 = peg$c3; + } + if (s1 === peg$FAILED) { + s1 = peg$c4; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c19(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseparams() { + var s0, s1, s2, s3, s4, s5, s6; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = []; + s4 = peg$parsews(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + } else { + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s5 = peg$c21; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c22); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parsenumber(); + if (s6 === peg$FAILED) { + s6 = peg$parseidentifier(); + if (s6 === peg$FAILED) { + s6 = peg$parseinline(); + } + } + if (s6 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s4, s6); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = []; + s4 = peg$parsews(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + } else { + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s5 = peg$c21; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c22); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parsenumber(); + if (s6 === peg$FAILED) { + s6 = peg$parseidentifier(); + if (s6 === peg$FAILED) { + s6 = peg$parseinline(); + } + } + if (s6 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s4, s6); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c24(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c20); } + } + + return s0; + } + + function peg$parsebodies() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = peg$parseld(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c16; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parsekey(); + if (s5 !== peg$FAILED) { + s6 = peg$parserd(); + if (s6 !== peg$FAILED) { + s7 = peg$parsebody(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s5, s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = peg$parseld(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c16; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parsekey(); + if (s5 !== peg$FAILED) { + s6 = peg$parserd(); + if (s6 !== peg$FAILED) { + s7 = peg$parsebody(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s5, s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c26(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c25); } + } + + return s0; + } + + function peg$parsereference() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + s2 = peg$parseidentifier(); + if (s2 !== peg$FAILED) { + s3 = peg$parsefilters(); + if (s3 !== peg$FAILED) { + s4 = peg$parserd(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c28(s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c27); } + } + + return s0; + } + + function peg$parsepartial() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 62) { + s2 = peg$c30; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c31); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s2 = peg$c32; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c33); } + } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parsews(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsews(); + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + s5 = peg$parsekey(); + if (s5 !== peg$FAILED) { + peg$reportedPos = s4; + s5 = peg$c34(s5); + } + s4 = s5; + if (s4 === peg$FAILED) { + s4 = peg$parseinline(); + } + if (s4 !== peg$FAILED) { + s5 = peg$parsecontext(); + if (s5 !== peg$FAILED) { + s6 = peg$parseparams(); + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsews(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsews(); + } + if (s7 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s8 = peg$c8; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s8 !== peg$FAILED) { + s9 = peg$parserd(); + if (s9 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c35(s2, s4, s5, s6); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c29); } + } + + return s0; + } + + function peg$parsefilters() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 124) { + s3 = peg$c37; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c38); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c18(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 124) { + s3 = peg$c37; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c38); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c18(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c39(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c36); } + } + + return s0; + } + + function peg$parsespecial() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 126) { + s2 = peg$c41; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c42); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parsekey(); + if (s3 !== peg$FAILED) { + s4 = peg$parserd(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c43(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c40); } + } + + return s0; + } + + function peg$parseidentifier() { + var s0, s1; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsepath(); + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c45(s1); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsekey(); + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c46(s1); + } + s0 = s1; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c44); } + } + + return s0; + } + + function peg$parsenumber() { + var s0, s1; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsefloat(); + if (s1 === peg$FAILED) { + s1 = peg$parseinteger(); + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c48(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c47); } + } + + return s0; + } + + function peg$parsefloat() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseinteger(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c50; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parseinteger(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseinteger(); + } + } else { + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c52(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c49); } + } + + return s0; + } + + function peg$parseinteger() { + var s0, s1, s2; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c56(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c53); } + } + + return s0; + } + + function peg$parsepath() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parsekey(); + if (s1 === peg$FAILED) { + s1 = peg$c4; + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + } + } else { + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c58(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s1 = peg$c50; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); + } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c59(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c57); } + } + + return s0; + } + + function peg$parsekey() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + if (peg$c61.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c62); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c63.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c64); } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c63.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c64); } + } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c65(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } + } + + return s0; + } + + function peg$parsearray() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$currPos; + s2 = peg$parselb(); + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + s4 = []; + if (peg$c54.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + if (peg$c54.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + } + } else { + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c67(s4); + } + s3 = s4; + if (s3 === peg$FAILED) { + s3 = peg$parseidentifier(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parserb(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s1; + s2 = peg$c68(s3); + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$c3; + } + } else { + peg$currPos = s1; + s1 = peg$c3; + } + } else { + peg$currPos = s1; + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + s2 = peg$parsearray_part(); + if (s2 === peg$FAILED) { + s2 = peg$c4; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c69(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + + return s0; + } + + function peg$parsearray_part() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c50; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c71(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c50; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsekey(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c71(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + s2 = peg$parsearray(); + if (s2 === peg$FAILED) { + s2 = peg$c4; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c72(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c70); } + } + + return s0; + } + + function peg$parseinline() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c74; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s2 = peg$c74; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c76(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c74; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseliteral(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c74; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c77(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c74; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseinline_part(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseinline_part(); + } + } else { + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c74; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c78(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + + return s0; + } + + function peg$parseinline_part() { + var s0, s1; + + s0 = peg$parsespecial(); + if (s0 === peg$FAILED) { + s0 = peg$parsereference(); + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseliteral(); + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c79(s1); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parsebuffer() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseeol(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c81(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + peg$silentFails++; + s5 = peg$parseraw(); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsecomment(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = peg$c6; + } else { + peg$currPos = s5; + s5 = peg$c3; + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseeol(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = peg$c6; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + if (s6 !== peg$FAILED) { + if (input.length > peg$currPos) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$currPos; + peg$silentFails++; + s5 = peg$parseraw(); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsecomment(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = peg$c6; + } else { + peg$currPos = s5; + s5 = peg$c3; + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseeol(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = peg$c6; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + if (s6 !== peg$FAILED) { + if (input.length > peg$currPos) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s7); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c84(s1); + } + s0 = s1; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c80); } + } + + return s0; + } + + function peg$parseliteral() { + var s0, s1, s2, s3, s4; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parseesc(); + if (s4 === peg$FAILED) { + if (peg$c86.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } + } + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$currPos; + s3 = peg$currPos; + peg$silentFails++; + s4 = peg$parsetag(); + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = peg$c6; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + if (s3 !== peg$FAILED) { + s4 = peg$parseesc(); + if (s4 === peg$FAILED) { + if (peg$c86.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } + } + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } else { + peg$currPos = s2; + s2 = peg$c3; + } + } + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c88(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c85); } + } + + return s0; + } + + function peg$parseesc() { + var s0, s1; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c89) { + s1 = peg$c89; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c90); } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c91(); + } + s0 = s1; + + return s0; + } + + function peg$parseraw() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c93) { + s1 = peg$c93; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c94); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c95) { + s5 = peg$c95; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c97(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c95) { + s5 = peg$c95; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c97(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c95) { + s3 = peg$c95; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c98(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c92); } + } + + return s0; + } + + function peg$parsecomment() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c100) { + s1 = peg$c100; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c101); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c102) { + s5 = peg$c102; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c83(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c102) { + s5 = peg$c102; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; + } + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c83(s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } else { + peg$currPos = s3; + s3 = peg$c3; + } + } + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c102) { + s3 = peg$c102; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c104(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + + return s0; + } + + function peg$parsetag() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parseld(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsews(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsews(); + } + if (s2 !== peg$FAILED) { + if (peg$c105.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c106); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsews(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsews(); + } + if (s4 !== peg$FAILED) { + s5 = []; + s6 = peg$currPos; + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parserd(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = peg$c6; + } else { + peg$currPos = s7; + s7 = peg$c3; + } + if (s7 !== peg$FAILED) { + s8 = peg$currPos; + peg$silentFails++; + s9 = peg$parseeol(); + peg$silentFails--; + if (s9 === peg$FAILED) { + s8 = peg$c6; + } else { + peg$currPos = s8; + s8 = peg$c3; + } + if (s8 !== peg$FAILED) { + if (input.length > peg$currPos) { + s9 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = peg$currPos; + s7 = peg$currPos; + peg$silentFails++; + s8 = peg$parserd(); + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = peg$c6; + } else { + peg$currPos = s7; + s7 = peg$c3; + } + if (s7 !== peg$FAILED) { + s8 = peg$currPos; + peg$silentFails++; + s9 = peg$parseeol(); + peg$silentFails--; + if (s9 === peg$FAILED) { + s8 = peg$c6; + } else { + peg$currPos = s8; + s8 = peg$c3; + } + if (s8 !== peg$FAILED) { + if (input.length > peg$currPos) { + s9 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } else { + peg$currPos = s6; + s6 = peg$c3; + } + } + } else { + s5 = peg$c3; + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsews(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsews(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parserd(); + if (s7 !== peg$FAILED) { + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + } else { + peg$currPos = s0; + s0 = peg$c3; + } + if (s0 === peg$FAILED) { + s0 = peg$parsereference(); + } + + return s0; + } + + function peg$parseld() { + var s0; + + if (input.charCodeAt(peg$currPos) === 123) { + s0 = peg$c107; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c108); } + } + + return s0; + } + + function peg$parserd() { + var s0; + + if (input.charCodeAt(peg$currPos) === 125) { + s0 = peg$c109; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c110); } + } + + return s0; + } + + function peg$parselb() { + var s0; + + if (input.charCodeAt(peg$currPos) === 91) { + s0 = peg$c111; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c112); } + } + + return s0; + } + + function peg$parserb() { + var s0; + + if (input.charCodeAt(peg$currPos) === 93) { + s0 = peg$c113; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c114); } + } + + return s0; + } + + function peg$parseeol() { + var s0; + + if (input.charCodeAt(peg$currPos) === 10) { + s0 = peg$c115; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c116); } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c117) { + s0 = peg$c117; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c118); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 13) { + s0 = peg$c119; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c120); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 8232) { + s0 = peg$c121; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c122); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 8233) { + s0 = peg$c123; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c124); } + } + } + } + } + } + + return s0; + } + + function peg$parsews() { + var s0; + + if (peg$c125.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c126); } + } + if (s0 === peg$FAILED) { + s0 = peg$parseeol(); + } + + return s0; + } + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail({ type: "end", description: "end of input" }); + } + + throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); + } + } + + return { + SyntaxError: SyntaxError, + parse: parse + }; +})(); + + // expose parser methods + dust.parse = parser.parse; + + return parser; +})); + + diff --git a/node_modules/dustjs-linkedin/lib/server.js b/node_modules/dustjs-linkedin/lib/server.js new file mode 100644 index 0000000..d2ef737 --- /dev/null +++ b/node_modules/dustjs-linkedin/lib/server.js @@ -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; diff --git a/node_modules/dustjs-linkedin/package.json b/node_modules/dustjs-linkedin/package.json new file mode 100644 index 0000000..cd9e04d --- /dev/null +++ b/node_modules/dustjs-linkedin/package.json @@ -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" +} diff --git a/package.json b/package.json index 1b7c21c..1e590c4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "morgan": "~1.3.0", "serve-favicon": "~2.1.3", "debug": "~2.0.0", - "dust":"*", + "consolidate":"*", + "dustjs-linkedin":"*", + "dustjs-helpers":"*", "nodeunit":"*", "mysql":"*", "node-memcache":"*" diff --git a/views/error.dust b/views/error.dust new file mode 100644 index 0000000..da3ef97 --- /dev/null +++ b/views/error.dust @@ -0,0 +1,12 @@ +{>layout/} + + +{{message} +

    {error.status}

    + {#error.stack} +
    +		{~n}
    +	
    + {/error.stack} +{/content} diff --git a/views/error.jade b/views/error.jade deleted file mode 100644 index 51ec12c..0000000 --- a/views/error.jade +++ /dev/null @@ -1,6 +0,0 @@ -extends layout - -block content - h1= message - h2= error.status - pre #{error.stack} diff --git a/views/index.dust b/views/index.dust new file mode 100644 index 0000000..1470928 --- /dev/null +++ b/views/index.dust @@ -0,0 +1,6 @@ +{>layout/} + +{{title} +

    Welcome to {title}

    +{/content} diff --git a/views/index.jade b/views/index.jade deleted file mode 100644 index 3d63b9a..0000000 --- a/views/index.jade +++ /dev/null @@ -1,5 +0,0 @@ -extends layout - -block content - h1= title - p Welcome to #{title} diff --git a/views/layout.dust b/views/layout.dust new file mode 100644 index 0000000..57c4780 --- /dev/null +++ b/views/layout.dust @@ -0,0 +1,15 @@ + + + + {title} + + + + {+content} + This is the base content. + {/content} + + + diff --git a/views/layout.jade b/views/layout.jade deleted file mode 100644 index b945f57..0000000 --- a/views/layout.jade +++ /dev/null @@ -1,7 +0,0 @@ -doctype html -html - head - title= title - link(rel='stylesheet', href='/stylesheets/style.css') - body - block content \ No newline at end of file