diff --git a/archive/dust-2.4.2.tar.gz b/archive/dust-2.4.2.tar.gz new file mode 100644 index 00000000..b2cadcf5 Binary files /dev/null and b/archive/dust-2.4.2.tar.gz differ diff --git a/archive/dust-2.4.2.zip b/archive/dust-2.4.2.zip new file mode 100644 index 00000000..8c7a626e Binary files /dev/null and b/archive/dust-2.4.2.zip differ diff --git a/bower.json b/bower.json index 1b92f8cc..aa6f0a16 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "dustjs-linkedin", - "version": "2.4.1", + "version": "2.4.2", "main": "dist/dust-full.min.js", "devDependencies": { "pegjs": "0.8.0" diff --git a/dist/dust-core.js b/dist/dust-core.js index cb09b127..de84df78 100644 --- a/dist/dust-core.js +++ b/dist/dust-core.js @@ -1,4 +1,4 @@ -/*! Dust - Asynchronous Templating - v2.4.1 +/*! Dust - Asynchronous Templating - v2.4.2 * http://linkedin.github.io/dustjs/ * Copyright (c) 2014 Aleksander Williams; Released under the MIT License */ (function(root) { @@ -346,7 +346,8 @@ try { return ctx.apply(ctxThis, arguments); } catch (err) { - return dust.log(err, ERROR); + dust.log(err, ERROR); + throw err; } }; } else { @@ -564,7 +565,12 @@ this.next = branch; this.flushable = true; - callback(branch); + try { + callback(branch); + } catch(e) { + dust.log(e, ERROR); + branch.setError(e); + } return cursor; }; @@ -607,7 +613,12 @@ Chunk.prototype.section = function(elem, context, bodies, params) { // anonymous functions if (typeof elem === 'function') { - elem = elem.apply(context.current(), [this, context, bodies, params]); + try { + elem = elem.apply(context.current(), [this, context, bodies, params]); + } catch(e) { + dust.log(e, ERROR); + return this.setError(e); + } // functions that return chunks are assumed to have handled the body and/or have modified the chunk // use that return value as the current chunk and go to the next method in the chain if (elem instanceof Chunk) { @@ -754,15 +765,15 @@ Chunk.prototype.helper = function(name, context, bodies, params) { var chunk = this; // handle invalid helpers, similar to invalid filters - try { - if(dust.helpers[name]) { + if(dust.helpers[name]) { + try { return dust.helpers[name](chunk, context, bodies, params); - } else { - dust.log('Invalid helper [' + name + ']', WARN); - return chunk; + } catch(e) { + dust.log('Error in ' + name + ' helper: ' + e, ERROR); + return chunk.setError(e); } - } catch (err) { - chunk.setError(err); + } else { + dust.log('Invalid helper [' + name + ']', WARN); return chunk; } }; diff --git a/dist/dust-core.min.js b/dist/dust-core.min.js index 2cad1033..0fe1509d 100644 --- a/dist/dust-core.min.js +++ b/dist/dust-core.min.js @@ -1,4 +1,4 @@ -/*! Dust - Asynchronous Templating - v2.4.1 +/*! 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){return dust.log(a,ERROR)}}:(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);return this.next=c,this.flushable=!0,a(c),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&&(a=a.apply(b.current(),[this,b,c,d]),a instanceof Chunk))return a;var e=c.block,f=c["else"];if(d&&(b=b.push(d)),dust.isArray(a)){if(e){var g=a.length,h=this;if(g>0){b.stack.head&&(b.stack.head.$len=g);for(var i=0;g>i;i++)b.stack.head&&(b.stack.head.$idx=i),h=e(h,b.push(a[i],i,g));return b.stack.head&&(b.stack.head.$idx=void 0,b.stack.head.$len=void 0),h}if(f)return f(this,b)}}else if(a===!0){if(e)return e(this,b)}else if(a||0===a){if(e)return e(this,b.push(a))}else if(f)return f(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;try{return dust.helpers[a]?dust.helpers[a](e,b,c,d):(dust.log("Invalid helper ["+a+"]",WARN),e)}catch(f){return e.setError(f),e}},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,GT=/>/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 +!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,GT=/>/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/dist/dust-full.js b/dist/dust-full.js index 54f01c14..040a6cc5 100644 --- a/dist/dust-full.js +++ b/dist/dust-full.js @@ -1,4 +1,4 @@ -/*! Dust - Asynchronous Templating - v2.4.1 +/*! Dust - Asynchronous Templating - v2.4.2 * http://linkedin.github.io/dustjs/ * Copyright (c) 2014 Aleksander Williams; Released under the MIT License */ (function(root) { @@ -346,7 +346,8 @@ try { return ctx.apply(ctxThis, arguments); } catch (err) { - return dust.log(err, ERROR); + dust.log(err, ERROR); + throw err; } }; } else { @@ -564,7 +565,12 @@ this.next = branch; this.flushable = true; - callback(branch); + try { + callback(branch); + } catch(e) { + dust.log(e, ERROR); + branch.setError(e); + } return cursor; }; @@ -607,7 +613,12 @@ Chunk.prototype.section = function(elem, context, bodies, params) { // anonymous functions if (typeof elem === 'function') { - elem = elem.apply(context.current(), [this, context, bodies, params]); + try { + elem = elem.apply(context.current(), [this, context, bodies, params]); + } catch(e) { + dust.log(e, ERROR); + return this.setError(e); + } // functions that return chunks are assumed to have handled the body and/or have modified the chunk // use that return value as the current chunk and go to the next method in the chain if (elem instanceof Chunk) { @@ -754,15 +765,15 @@ Chunk.prototype.helper = function(name, context, bodies, params) { var chunk = this; // handle invalid helpers, similar to invalid filters - try { - if(dust.helpers[name]) { + if(dust.helpers[name]) { + try { return dust.helpers[name](chunk, context, bodies, params); - } else { - dust.log('Invalid helper [' + name + ']', WARN); - return chunk; + } catch(e) { + dust.log('Error in ' + name + ' helper: ' + e, ERROR); + return chunk.setError(e); } - } catch (err) { - chunk.setError(err); + } else { + dust.log('Invalid helper [' + name + ']', WARN); return chunk; } }; @@ -869,2811 +880,2650 @@ factory(root.dust); } }(this, function(dust) { - var parser = (function(){ + var parser = (function() { /* - * Generated by PEG.js 0.7.0. + * Generated by PEG.js 0.8.0. * * http://pegjs.majda.cz/ */ - - 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. - * - * For portability, we also escape escape all control and non-ASCII - * characters. Note that "\0" and "\v" escape sequences are not used - * because JSHint does not like the first and IE the second. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\x08/g, '\\b') // backspace - .replace(/\t/g, '\\t') // horizontal tab - .replace(/\n/g, '\\n') // line feed - .replace(/\f/g, '\\f') // form feed - .replace(/\r/g, '\\r') // carriage return - .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) - + '"'; + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); } - - 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, startRule) { - var parseFunctions = { - "body": parse_body, - "part": parse_part, - "section": parse_section, - "sec_tag_start": parse_sec_tag_start, - "end_tag": parse_end_tag, - "context": parse_context, - "params": parse_params, - "bodies": parse_bodies, - "reference": parse_reference, - "partial": parse_partial, - "filters": parse_filters, - "special": parse_special, - "identifier": parse_identifier, - "number": parse_number, - "float": parse_float, - "integer": parse_integer, - "path": parse_path, - "key": parse_key, - "array": parse_array, - "array_part": parse_array_part, - "inline": parse_inline, - "inline_part": parse_inline_part, - "buffer": parse_buffer, - "literal": parse_literal, - "esc": parse_esc, - "raw": parse_raw, - "comment": parse_comment, - "tag": parse_tag, - "ld": parse_ld, - "rd": parse_rd, - "lb": parse_lb, - "rb": parse_rb, - "eol": parse_eol, - "ws": parse_ws - }; - - if (startRule !== undefined) { - if (parseFunctions[startRule] === undefined) { - throw new Error("Invalid rule name: " + quote(startRule) + "."); - } - } else { - startRule = "body"; - } - - var pos = { offset: 0, line: 1, column: 1, seenCR: false }; - var reportFailures = 0; - var rightmostFailuresPos = { offset: 0, line: 1, column: 1, seenCR: false }; - var rightmostFailuresExpected = []; - - 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); - var escapeChar; - var length; - - if (charCode <= 0xFF) { - escapeChar = 'x'; - length = 2; - } else { - escapeChar = 'u'; - length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); - } - - function clone(object) { - var result = {}; - for (var key in object) { - result[key] = object[key]; - } - return result; - } - - function advance(pos, n) { - var endOffset = pos.offset + n; - - for (var offset = pos.offset; offset < endOffset; offset++) { - var ch = input.charAt(offset); + + 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 (!pos.seenCR) { pos.line++; } - pos.column = 1; - pos.seenCR = false; + if (!details.seenCR) { details.line++; } + details.column = 1; + details.seenCR = false; } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - pos.line++; - pos.column = 1; - pos.seenCR = true; + details.line++; + details.column = 1; + details.seenCR = true; } else { - pos.column++; - pos.seenCR = false; + details.column++; + details.seenCR = false; } } - - pos.offset += n; } - - function matchFailed(failure) { - if (pos.offset < rightmostFailuresPos.offset) { - return; - } - - if (pos.offset > rightmostFailuresPos.offset) { - rightmostFailuresPos = clone(pos); - rightmostFailuresExpected = []; + + if (peg$cachedPos !== pos) { + if (peg$cachedPos > pos) { + peg$cachedPos = 0; + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; } - - rightmostFailuresExpected.push(failure); - } - - function parse_body() { - var result0, result1; - var pos0; - - pos0 = clone(pos); - result0 = []; - result1 = parse_part(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_part(); + 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++; + } } - if (result0 !== null) { - result0 = (function(offset, line, column, p) { return ["body"].concat(p).concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0); + } + + 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); }); } - if (result0 === null) { - pos = clone(pos0); + + var expectedDescs = new Array(expected.length), + expectedDesc, foundDesc, i; + + for (i = 0; i < expected.length; i++) { + expectedDescs[i] = expected[i].description; } - return result0; - } - - function parse_part() { - var result0; - - result0 = parse_raw(); - if (result0 === null) { - result0 = parse_comment(); - if (result0 === null) { - result0 = parse_section(); - if (result0 === null) { - result0 = parse_partial(); - if (result0 === null) { - result0 = parse_special(); - if (result0 === null) { - result0 = parse_reference(); - if (result0 === null) { - result0 = parse_buffer(); - } + + 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 result0; - } - - function parse_section() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_sec_tag_start(); - if (result0 !== null) { - result1 = []; - result2 = parse_ws(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_ws(); - } - if (result1 !== null) { - result2 = parse_rd(); - if (result2 !== null) { - result3 = parse_body(); - if (result3 !== null) { - result4 = parse_bodies(); - if (result4 !== null) { - result5 = parse_end_tag(); - result5 = result5 !== null ? result5 : ""; - if (result5 !== null) { - result6 = (function(offset, line, column, t, b, e, n) {if( (!n) || (t[1].text !== n.text) ) { throw new Error("Expected end tag for "+t[1].text+" but it was not found. At line : "+line+", column : " + column)} return true;})(pos.offset, pos.line, pos.column, result0, result3, result4, result5) ? "" : null; - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = clone(pos1); - } + } + + 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 !== null) { - result0 = (function(offset, line, column, t, b, e, n) { e.push(["param", ["literal", "block"], b]); t.push(e); return t.concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[0], result0[3], result0[4], result0[5]); - } - if (result0 === null) { - pos = clone(pos0); - } - if (result0 === null) { - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_sec_tag_start(); - if (result0 !== null) { - result1 = []; - result2 = parse_ws(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_ws(); - } - if (result1 !== null) { - if (input.charCodeAt(pos.offset) === 47) { - result2 = "/"; - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result2 !== null) { - result3 = parse_rd(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = clone(pos1); - } + } 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, t) { t.push(["bodies"]); return t.concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[0]); - } - if (result0 === null) { - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } + } else { + peg$currPos = s0; + s0 = peg$c3; } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("section"); - } - return result0; - } - - function parse_sec_tag_start() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_ld(); - if (result0 !== null) { - if (/^[#?^<+@%]/.test(input.charAt(pos.offset))) { - result1 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[#?^<+@%]"); - } - } - if (result1 !== null) { - result2 = []; - result3 = parse_ws(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_ws(); - } - if (result2 !== null) { - result3 = parse_identifier(); - if (result3 !== null) { - result4 = parse_context(); - if (result4 !== null) { - result5 = parse_params(); - if (result5 !== null) { - result0 = [result0, result1, result2, result3, result4, result5]; - } else { - result0 = null; - pos = clone(pos1); - } + } + 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, t, n, c, p) { return [t, n, c, p] })(pos0.offset, pos0.line, pos0.column, result0[1], result0[3], result0[4], result0[5]); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 === null) { - pos = clone(pos0); - } - return result0; - } - - function parse_end_tag() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_ld(); - if (result0 !== null) { - if (input.charCodeAt(pos.offset) === 47) { - result1 = "/"; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result1 !== null) { - result2 = []; - result3 = parse_ws(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_ws(); - } - if (result2 !== null) { - result3 = parse_identifier(); - if (result3 !== null) { - result4 = []; - result5 = parse_ws(); - while (result5 !== null) { - result4.push(result5); - result5 = parse_ws(); - } - if (result4 !== null) { - result5 = parse_rd(); - if (result5 !== null) { - result0 = [result0, result1, result2, result3, result4, result5]; - } else { - result0 = null; - pos = clone(pos1); - } + } 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 !== null) { - result0 = (function(offset, line, column, n) { return n })(pos0.offset, pos0.line, pos0.column, result0[3]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("end tag"); - } - return result0; - } - - function parse_context() { - var result0, result1; - var pos0, pos1, pos2; - - pos0 = clone(pos); - pos1 = clone(pos); - pos2 = clone(pos); - if (input.charCodeAt(pos.offset) === 58) { - result0 = ":"; - advance(pos, 1); + } 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 { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } + 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(); } - if (result0 !== null) { - result1 = parse_identifier(); - if (result1 !== null) { - result0 = [result0, result1]; + } 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 { - result0 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result0 = null; - pos = clone(pos2); - } - if (result0 !== null) { - result0 = (function(offset, line, column, n) {return n})(pos1.offset, pos1.line, pos1.column, result0[1]); + peg$currPos = s2; + s2 = peg$c3; } - if (result0 === null) { - pos = clone(pos1); - } - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result0 = (function(offset, line, column, n) { return n ? ["context", n] : ["context"] })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - return result0; - } - - function parse_params() { - var result0, result1, result2, result3, result4; - var pos0, pos1, pos2; - - reportFailures++; - pos0 = clone(pos); - result0 = []; - pos1 = clone(pos); - pos2 = clone(pos); - result2 = parse_ws(); - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - result2 = parse_ws(); + } 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 { - result1 = null; - } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - if (input.charCodeAt(pos.offset) === 61) { - result3 = "="; - advance(pos, 1); + 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 { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result3 !== null) { - result4 = parse_number(); - if (result4 === null) { - result4 = parse_identifier(); - if (result4 === null) { - result4 = parse_inline(); + 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 (result4 !== null) { - result1 = [result1, result2, result3, result4]; + if (s6 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c23(s4, s6); + s2 = s3; } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, k, v) {return ["param", ["literal", k], v]})(pos1.offset, pos1.line, pos1.column, result1[1], result1[3]); + peg$currPos = s2; + s2 = peg$c3; } - if (result1 === null) { - pos = clone(pos1); - } - while (result1 !== null) { - result0.push(result1); - pos1 = clone(pos); - pos2 = clone(pos); - result2 = parse_ws(); - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - result2 = parse_ws(); - } - } else { - result1 = null; - } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - if (input.charCodeAt(pos.offset) === 61) { - result3 = "="; - advance(pos, 1); - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result3 !== null) { - result4 = parse_number(); - if (result4 === null) { - result4 = parse_identifier(); - if (result4 === null) { - result4 = parse_inline(); - } - } - if (result4 !== null) { - result1 = [result1, result2, result3, result4]; - } else { - result1 = null; - pos = clone(pos2); - } + } + 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 { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, k, v) {return ["param", ["literal", k], v]})(pos1.offset, pos1.line, pos1.column, result1[1], result1[3]); - } - if (result1 === null) { - pos = clone(pos1); + peg$currPos = s2; + s2 = peg$c3; } + } else { + peg$currPos = s2; + s2 = peg$c3; } - if (result0 !== null) { - result0 = (function(offset, line, column, p) { return ["params"].concat(p) })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("params"); - } - return result0; - } - - function parse_bodies() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2; - - reportFailures++; - pos0 = clone(pos); - result0 = []; - pos1 = clone(pos); - pos2 = clone(pos); - result1 = parse_ld(); - if (result1 !== null) { - if (input.charCodeAt(pos.offset) === 58) { - result2 = ":"; - advance(pos, 1); + } 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 { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_key(); - if (result3 !== null) { - result4 = parse_rd(); - if (result4 !== null) { - result5 = parse_body(); - if (result5 !== null) { - result1 = [result1, result2, result3, result4, result5]; + 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 { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, k, v) {return ["param", ["literal", k], v]})(pos1.offset, pos1.line, pos1.column, result1[2], result1[4]); + peg$currPos = s2; + s2 = peg$c3; } - if (result1 === null) { - pos = clone(pos1); - } - while (result1 !== null) { - result0.push(result1); - pos1 = clone(pos); - pos2 = clone(pos); - result1 = parse_ld(); - if (result1 !== null) { - if (input.charCodeAt(pos.offset) === 58) { - result2 = ":"; - advance(pos, 1); + } + 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 { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } + peg$currPos = s0; + s0 = peg$c3; } - if (result2 !== null) { - result3 = parse_key(); - if (result3 !== null) { - result4 = parse_rd(); - if (result4 !== null) { - result5 = parse_body(); - if (result5 !== null) { - result1 = [result1, result2, result3, result4, result5]; + } 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 { - result1 = null; - pos = clone(pos2); + peg$currPos = s0; + s0 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s0; + s0 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s0; + s0 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s0; + s0 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, k, v) {return ["param", ["literal", k], v]})(pos1.offset, pos1.line, pos1.column, result1[2], result1[4]); + peg$currPos = s0; + s0 = peg$c3; } - if (result1 === null) { - pos = clone(pos1); - } - } - if (result0 !== null) { - result0 = (function(offset, line, column, p) { return ["bodies"].concat(p) })(pos0.offset, pos0.line, pos0.column, result0); + } else { + peg$currPos = s0; + s0 = peg$c3; } - if (result0 === null) { - pos = clone(pos0); + } 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; } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("bodies"); + } 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; } - return result0; - } - - function parse_reference() { - var result0, result1, result2, result3; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_ld(); - if (result0 !== null) { - result1 = parse_identifier(); - if (result1 !== null) { - result2 = parse_filters(); - if (result2 !== null) { - result3 = parse_rd(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } + } + 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 { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, n, f) { return ["reference", n, f].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[1], result0[2]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("reference"); - } - return result0; - } - - function parse_partial() { - var result0, result1, result2, result3, result4, result5, result6, result7, result8; - var pos0, pos1, pos2; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_ld(); - if (result0 !== null) { - if (input.charCodeAt(pos.offset) === 62) { - result1 = ">"; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\">\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos.offset) === 43) { - result1 = "+"; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - } - if (result1 !== null) { - result2 = []; - result3 = parse_ws(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_ws(); - } - if (result2 !== null) { - pos2 = clone(pos); - result3 = parse_key(); - if (result3 !== null) { - result3 = (function(offset, line, column, k) {return ["literal", k]})(pos2.offset, pos2.line, pos2.column, result3); - } - if (result3 === null) { - pos = clone(pos2); - } - if (result3 === null) { - result3 = parse_inline(); - } - if (result3 !== null) { - result4 = parse_context(); - if (result4 !== null) { - result5 = parse_params(); - if (result5 !== null) { - result6 = []; - result7 = parse_ws(); - while (result7 !== null) { - result6.push(result7); - result7 = parse_ws(); - } - if (result6 !== null) { - if (input.charCodeAt(pos.offset) === 47) { - result7 = "/"; - advance(pos, 1); - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result7 !== null) { - result8 = parse_rd(); - if (result8 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8]; - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } + 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, s, n, c, p) { var key = (s ===">")? "partial" : s; return [key, n, c, p].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[1], result0[3], result0[4], result0[5]); - } - if (result0 === null) { - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("partial"); - } - return result0; - } - - function parse_filters() { - var result0, result1, result2; - var pos0, pos1, pos2; - - reportFailures++; - pos0 = clone(pos); - result0 = []; - pos1 = clone(pos); - pos2 = clone(pos); - if (input.charCodeAt(pos.offset) === 124) { - result1 = "|"; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"|\""); - } + } 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); } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = clone(pos2); - } + 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 { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, n) {return n})(pos1.offset, pos1.line, pos1.column, result1[1]); - } - if (result1 === null) { - pos = clone(pos1); + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } } - while (result1 !== null) { - result0.push(result1); - pos1 = clone(pos); - pos2 = clone(pos); - if (input.charCodeAt(pos.offset) === 124) { - result1 = "|"; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"|\""); - } - } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = clone(pos2); + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parseinteger(); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseinteger(); } } else { - result1 = null; - pos = clone(pos2); + s3 = peg$c3; } - if (result1 !== null) { - result1 = (function(offset, line, column, n) {return n})(pos1.offset, pos1.line, pos1.column, result1[1]); - } - if (result1 === null) { - pos = clone(pos1); - } - } - if (result0 !== null) { - result0 = (function(offset, line, column, f) { return ["filters"].concat(f) })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("filters"); - } - return result0; - } - - function parse_special() { - var result0, result1, result2, result3; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_ld(); - if (result0 !== null) { - if (input.charCodeAt(pos.offset) === 126) { - result1 = "~"; - advance(pos, 1); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c52(s1, s3); + s0 = s1; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - result3 = parse_rd(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, k) { return ["special", k].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[2]); - } - if (result0 === null) { - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("special"); - } - return result0; - } - - function parse_identifier() { - var result0; - var pos0; - - reportFailures++; - pos0 = clone(pos); - result0 = parse_path(); - if (result0 !== null) { - result0 = (function(offset, line, column, p) { var arr = ["path"].concat(p); arr.text = p[1].join('.'); return arr; })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - if (result0 === null) { - pos0 = clone(pos); - result0 = parse_key(); - if (result0 !== null) { - result0 = (function(offset, line, column, k) { var arr = ["key", k]; arr.text = k; return arr; })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); + } 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); } } } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("identifier"); - } - return result0; - } - - function parse_number() { - var result0; - var pos0; - - reportFailures++; - pos0 = clone(pos); - result0 = parse_float(); - if (result0 === null) { - result0 = parse_integer(); - } - if (result0 !== null) { - result0 = (function(offset, line, column, n) { return ['literal', n]; })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("number"); + } 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(); } - return result0; - } - - function parse_float() { - var result0, result1, result2, result3; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_integer(); - if (result0 !== null) { - if (input.charCodeAt(pos.offset) === 46) { - result1 = "."; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsearray_part(); + if (s3 === peg$FAILED) { + s3 = peg$parsearray(); } } - if (result1 !== null) { - result3 = parse_integer(); - if (result3 !== null) { - result2 = []; - while (result3 !== null) { - result2.push(result3); - result3 = parse_integer(); - } - } else { - result2 = null; - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, l, r) { return parseFloat(l + "." + r.join('')); })(pos0.offset, pos0.line, pos0.column, result0[0], result0[2]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("float"); + s2 = peg$c3; } - return result0; - } - - function parse_integer() { - var result0, result1; - var pos0; - - reportFailures++; - pos0 = clone(pos); - if (/^[0-9]/.test(input.charAt(pos.offset))) { - result1 = input.charAt(pos.offset); - advance(pos, 1); + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c58(s1, s2); + s0 = s1; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } + peg$currPos = s0; + s0 = peg$c3; } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[0-9]/.test(input.charAt(pos.offset))) { - result1 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - } + } 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 { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, line, column, digits) { return parseInt(digits.join(""), 10); })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("integer"); - } - return result0; - } - - function parse_path() { - var result0, result1, result2; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_key(); - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result2 = parse_array_part(); - if (result2 === null) { - result2 = parse_array(); - } - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - result2 = parse_array_part(); - if (result2 === null) { - result2 = parse_array(); - } - } + 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 { - result1 = null; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 !== null) { - result0 = (function(offset, line, column, 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]]); - })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - if (result0 === null) { - pos0 = clone(pos); - pos1 = clone(pos); - if (input.charCodeAt(pos.offset) === 46) { - result0 = "."; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result0 !== null) { - result1 = []; - result2 = parse_array_part(); - if (result2 === null) { - result2 = parse_array(); - } - while (result2 !== null) { - result1.push(result2); - result2 = parse_array_part(); - if (result2 === null) { - result2 = parse_array(); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = clone(pos1); - } + } + 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 { - result0 = null; - pos = clone(pos1); + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c64); } } - if (result0 !== null) { - result0 = (function(offset, line, column, d) { - if (d.length > 0) { - return [true, d[0]].concat([['line', line], ['col', column]]); - } - return [true, []].concat([['line', line], ['col', column]]); - })(pos0.offset, pos0.line, pos0.column, result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("path"); } - return result0; - } - - function parse_key() { - var result0, result1, result2; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - if (/^[a-zA-Z_$]/.test(input.charAt(pos.offset))) { - result0 = input.charAt(pos.offset); - advance(pos, 1); + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c65(s1, s2); + s0 = s1; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z_$]"); - } + peg$currPos = s0; + s0 = peg$c3; } - if (result0 !== null) { - result1 = []; - if (/^[0-9a-zA-Z_$\-]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[0-9a-zA-Z_$\\-]"); - } - } - while (result2 !== null) { - result1.push(result2); - if (/^[0-9a-zA-Z_$\-]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); + } 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 { - result2 = null; - if (reportFailures === 0) { - matchFailed("[0-9a-zA-Z_$\\-]"); - } + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } } } - if (result1 !== null) { - result0 = [result0, result1]; + } 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s1; + s1 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, h, t) { return h + t.join('') })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]); + peg$currPos = s1; + s1 = peg$c3; } - if (result0 === null) { - pos = clone(pos0); + } 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; } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("key"); + } 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; } - return result0; - } - - function parse_array() { - var result0, result1, result2; - var pos0, pos1, pos2, pos3, pos4; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - pos2 = clone(pos); - pos3 = clone(pos); - result0 = parse_lb(); - if (result0 !== null) { - pos4 = clone(pos); - if (/^[0-9]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - if (/^[0-9]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - } + } 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 { - result1 = null; - } - if (result1 !== null) { - result1 = (function(offset, line, column, n) {return n.join('')})(pos4.offset, pos4.line, pos4.column, result1); - } - if (result1 === null) { - pos = clone(pos4); - } - if (result1 === null) { - result1 = parse_identifier(); - } - if (result1 !== null) { - result2 = parse_rb(); - if (result2 !== null) { - result0 = [result0, result1, result2]; + 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 { - result0 = null; - pos = clone(pos3); + peg$currPos = s2; + s2 = peg$c3; } } else { - result0 = null; - pos = clone(pos3); + peg$currPos = s2; + s2 = peg$c3; } - } else { - result0 = null; - pos = clone(pos3); - } - if (result0 !== null) { - result0 = (function(offset, line, column, a) {return a; })(pos2.offset, pos2.line, pos2.column, result0[1]); } - if (result0 === null) { - pos = clone(pos2); + } else { + s1 = peg$c3; + } + if (s1 !== peg$FAILED) { + s2 = peg$parsearray(); + if (s2 === peg$FAILED) { + s2 = peg$c4; } - if (result0 !== null) { - result1 = parse_array_part(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = clone(pos1); - } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c72(s1, s2); + s0 = s1; } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, i, nk) { if(nk) { nk.unshift(i); } else {nk = [i] } return nk; })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("array"); + peg$currPos = s0; + s0 = peg$c3; } - return result0; - } - - function parse_array_part() { - var result0, result1, result2; - var pos0, pos1, pos2, pos3; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - pos2 = clone(pos); - pos3 = clone(pos); - if (input.charCodeAt(pos.offset) === 46) { - result1 = "."; - advance(pos, 1); + } 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 { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = clone(pos3); - } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c76(); + s0 = s1; } else { - result1 = null; - pos = clone(pos3); - } - if (result1 !== null) { - result1 = (function(offset, line, column, k) {return k})(pos2.offset, pos2.line, pos2.column, result1[1]); - } - if (result1 === null) { - pos = clone(pos2); + peg$currPos = s0; + s0 = peg$c3; } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - pos2 = clone(pos); - pos3 = clone(pos); - if (input.charCodeAt(pos.offset) === 46) { - result1 = "."; - advance(pos, 1); + } 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 { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } } - if (result1 !== null) { - result2 = parse_key(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = clone(pos3); - } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c77(s2); + s0 = s1; } else { - result1 = null; - pos = clone(pos3); + peg$currPos = s0; + s0 = peg$c3; } - if (result1 !== null) { - result1 = (function(offset, line, column, k) {return k})(pos2.offset, pos2.line, pos2.column, result1[1]); - } - if (result1 === null) { - pos = clone(pos2); - } - } - } else { - result0 = null; - } - if (result0 !== null) { - result1 = parse_array(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, d, a) { if (a) { return d.concat(a); } else { return d; } })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("array_part"); - } - return result0; - } - - function parse_inline() { - var result0, result1, result2; - var pos0, pos1; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - if (input.charCodeAt(pos.offset) === 34) { - result0 = "\""; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result0 !== null) { - if (input.charCodeAt(pos.offset) === 34) { - result1 = "\""; - advance(pos, 1); - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = clone(pos1); - } - } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column) { return ["literal", ""].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column); - } - if (result0 === null) { - pos = clone(pos0); - } - if (result0 === null) { - pos0 = clone(pos); - pos1 = clone(pos); - if (input.charCodeAt(pos.offset) === 34) { - result0 = "\""; - advance(pos, 1); + 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 { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result0 !== null) { - result1 = parse_literal(); - if (result1 !== null) { - if (input.charCodeAt(pos.offset) === 34) { - result2 = "\""; - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = clone(pos1); + 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 { - result0 = null; - pos = clone(pos1); + s2 = peg$c3; } - } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, l) { return ["literal", l].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - if (result0 === null) { - pos0 = clone(pos); - pos1 = clone(pos); - if (input.charCodeAt(pos.offset) === 34) { - result0 = "\""; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result0 !== null) { - result2 = parse_inline_part(); - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - result2 = parse_inline_part(); - } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c74; + peg$currPos++; } else { - result1 = null; + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } } - if (result1 !== null) { - if (input.charCodeAt(pos.offset) === 34) { - result2 = "\""; - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"\\\"\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = clone(pos1); - } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c78(s2); + s0 = s1; } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, p) { return ["body"].concat(p).concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[1]); - } - if (result0 === null) { - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } + } else { + peg$currPos = s0; + s0 = peg$c3; } } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("inline"); - } - return result0; - } - - function parse_inline_part() { - var result0; - var pos0; - - result0 = parse_special(); - if (result0 === null) { - result0 = parse_reference(); - if (result0 === null) { - pos0 = clone(pos); - result0 = parse_literal(); - if (result0 !== null) { - result0 = (function(offset, line, column, l) { return ["buffer", l] })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } + } + 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 result0; - } - - function parse_buffer() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1, pos2, pos3; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - result0 = parse_eol(); - if (result0 !== null) { - result1 = []; - result2 = parse_ws(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_ws(); - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = clone(pos1); - } + } + + 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 { - result0 = null; - pos = clone(pos1); - } - if (result0 !== null) { - result0 = (function(offset, line, column, e, w) { return ["format", e, w.join('')].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[0], result0[1]); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 === null) { - pos = clone(pos0); - } - if (result0 === null) { - pos0 = clone(pos); - pos1 = clone(pos); - pos2 = clone(pos); - pos3 = clone(pos); - reportFailures++; - result1 = parse_tag(); - reportFailures--; - if (result1 === null) { - result1 = ""; + } 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 { - result1 = null; - pos = clone(pos3); - } - if (result1 !== null) { - pos3 = clone(pos); - reportFailures++; - result2 = parse_raw(); - reportFailures--; - if (result2 === null) { - result2 = ""; + 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 { - result2 = null; - pos = clone(pos3); - } - if (result2 !== null) { - pos3 = clone(pos); - reportFailures++; - result3 = parse_comment(); - reportFailures--; - if (result3 === null) { - result3 = ""; + 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 { - result3 = null; - pos = clone(pos3); + peg$currPos = s6; + s6 = peg$c3; } - if (result3 !== null) { - pos3 = clone(pos); - reportFailures++; - result4 = parse_eol(); - reportFailures--; - if (result4 === null) { - result4 = ""; + if (s6 !== peg$FAILED) { + if (input.length > peg$currPos) { + s7 = input.charAt(peg$currPos); + peg$currPos++; } else { - result4 = null; - pos = clone(pos3); + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - if (result4 !== null) { - if (input.length > pos.offset) { - result5 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result5 !== null) { - result1 = [result1, result2, result3, result4, result5]; - } else { - result1 = null; - pos = clone(pos2); - } + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s7); + s2 = s3; } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, c) {return c})(pos1.offset, pos1.line, pos1.column, result1[4]); - } - if (result1 === null) { - pos = clone(pos1); + peg$currPos = s2; + s2 = peg$c3; } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - pos1 = clone(pos); - pos2 = clone(pos); - pos3 = clone(pos); - reportFailures++; - result1 = parse_tag(); - reportFailures--; - if (result1 === null) { - result1 = ""; + } 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 { - result1 = null; - pos = clone(pos3); + peg$currPos = s4; + s4 = peg$c3; } - if (result1 !== null) { - pos3 = clone(pos); - reportFailures++; - result2 = parse_raw(); - reportFailures--; - if (result2 === null) { - result2 = ""; + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parsecomment(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = peg$c6; } else { - result2 = null; - pos = clone(pos3); + peg$currPos = s5; + s5 = peg$c3; } - if (result2 !== null) { - pos3 = clone(pos); - reportFailures++; - result3 = parse_comment(); - reportFailures--; - if (result3 === null) { - result3 = ""; + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + s7 = peg$parseeol(); + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = peg$c6; } else { - result3 = null; - pos = clone(pos3); + peg$currPos = s6; + s6 = peg$c3; } - if (result3 !== null) { - pos3 = clone(pos); - reportFailures++; - result4 = parse_eol(); - reportFailures--; - if (result4 === null) { - result4 = ""; + if (s6 !== peg$FAILED) { + if (input.length > peg$currPos) { + s7 = input.charAt(peg$currPos); + peg$currPos++; } else { - result4 = null; - pos = clone(pos3); + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - if (result4 !== null) { - if (input.length > pos.offset) { - result5 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result5 !== null) { - result1 = [result1, result2, result3, result4, result5]; - } else { - result1 = null; - pos = clone(pos2); - } + if (s7 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s7); + s2 = s3; } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); + peg$currPos = s2; + s2 = peg$c3; } } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, c) {return c})(pos1.offset, pos1.line, pos1.column, result1[4]); - } - if (result1 === null) { - pos = clone(pos1); + peg$currPos = s2; + s2 = peg$c3; } + } else { + peg$currPos = s2; + s2 = peg$c3; } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, line, column, b) { return ["buffer", b.join('')].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); } - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("buffer"); - } - return result0; - } - - function parse_literal() { - var result0, result1, result2; - var pos0, pos1, pos2, pos3; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - pos2 = clone(pos); - pos3 = clone(pos); - reportFailures++; - result1 = parse_tag(); - reportFailures--; - if (result1 === null) { - result1 = ""; } else { - result1 = null; - pos = clone(pos3); + s1 = peg$c3; } - if (result1 !== null) { - result2 = parse_esc(); - if (result2 === null) { - if (/^[^"]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^\"]"); - } - } - } - if (result2 !== null) { - result1 = [result1, result2]; + 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 { - result1 = null; - pos = clone(pos2); + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } } - } else { - result1 = null; - pos = clone(pos2); } - if (result1 !== null) { - result1 = (function(offset, line, column, c) {return c})(pos1.offset, pos1.line, pos1.column, result1[1]); - } - if (result1 === null) { - pos = clone(pos1); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c83(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c3; } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - pos1 = clone(pos); - pos2 = clone(pos); - pos3 = clone(pos); - reportFailures++; - result1 = parse_tag(); - reportFailures--; - if (result1 === null) { - result1 = ""; - } else { - result1 = null; - pos = clone(pos3); - } - if (result1 !== null) { - result2 = parse_esc(); - if (result2 === null) { - if (/^[^"]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[^\"]"); - } - } - } - if (result2 !== null) { - result1 = [result1, result2]; + } 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 { - result1 = null; - pos = clone(pos2); + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c87); } } - } else { - result1 = null; - pos = clone(pos2); - } - if (result1 !== null) { - result1 = (function(offset, line, column, c) {return c})(pos1.offset, pos1.line, pos1.column, result1[1]); } - if (result1 === null) { - pos = clone(pos1); + 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 { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, line, column, b) { return b.join('') })(pos0.offset, pos0.line, pos0.column, result0); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("literal"); } - return result0; - } - - function parse_esc() { - var result0; - var pos0; - - pos0 = clone(pos); - if (input.substr(pos.offset, 2) === "\\\"") { - result0 = "\\\""; - advance(pos, 2); + } 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 { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\\\"\""); - } - } - if (result0 !== null) { - result0 = (function(offset, line, column) { return '"' })(pos0.offset, pos0.line, pos0.column); + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } } - if (result0 === null) { - pos = clone(pos0); - } - return result0; - } - - function parse_raw() { - var result0, result1, result2, result3; - var pos0, pos1, pos2, pos3, pos4; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - if (input.substr(pos.offset, 2) === "{`") { - result0 = "{`"; - advance(pos, 2); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"{`\""); - } + peg$currPos = s4; + s4 = peg$c3; } - if (result0 !== null) { - result1 = []; - pos2 = clone(pos); - pos3 = clone(pos); - pos4 = clone(pos); - reportFailures++; - if (input.substr(pos.offset, 2) === "`}") { - result2 = "`}"; - advance(pos, 2); + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"`}\""); - } + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - reportFailures--; - if (result2 === null) { - result2 = ""; + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c97(s5); + s3 = s4; } else { - result2 = null; - pos = clone(pos4); + peg$currPos = s3; + s3 = peg$c3; } - if (result2 !== null) { - if (input.length > pos.offset) { - result3 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = clone(pos3); - } + } 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 { - result2 = null; - pos = clone(pos3); - } - if (result2 !== null) { - result2 = (function(offset, line, column, char) {return char})(pos2.offset, pos2.line, pos2.column, result2[1]); + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } } - if (result2 === null) { - pos = clone(pos2); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; } - while (result2 !== null) { - result1.push(result2); - pos2 = clone(pos); - pos3 = clone(pos); - pos4 = clone(pos); - reportFailures++; - if (input.substr(pos.offset, 2) === "`}") { - result2 = "`}"; - advance(pos, 2); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"`}\""); - } - } - reportFailures--; - if (result2 === null) { - result2 = ""; + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; } else { - result2 = null; - pos = clone(pos4); + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - if (result2 !== null) { - if (input.length > pos.offset) { - result3 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = clone(pos3); - } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c97(s5); + s3 = s4; } else { - result2 = null; - pos = clone(pos3); - } - if (result2 !== null) { - result2 = (function(offset, line, column, char) {return char})(pos2.offset, pos2.line, pos2.column, result2[1]); - } - if (result2 === null) { - pos = clone(pos2); + peg$currPos = s3; + s3 = peg$c3; } + } else { + peg$currPos = s3; + s3 = peg$c3; } - if (result1 !== null) { - if (input.substr(pos.offset, 2) === "`}") { - result2 = "`}"; - advance(pos, 2); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"`}\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = clone(pos1); - } + } + 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 !== null) { - result0 = (function(offset, line, column, rawText) { return ["raw", rawText.join('')].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("raw"); + } 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); } } - return result0; - } - - function parse_comment() { - var result0, result1, result2, result3; - var pos0, pos1, pos2, pos3, pos4; - - reportFailures++; - pos0 = clone(pos); - pos1 = clone(pos); - if (input.substr(pos.offset, 2) === "{!") { - result0 = "{!"; - advance(pos, 2); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"{!\""); - } + peg$currPos = s4; + s4 = peg$c3; } - if (result0 !== null) { - result1 = []; - pos2 = clone(pos); - pos3 = clone(pos); - pos4 = clone(pos); - reportFailures++; - if (input.substr(pos.offset, 2) === "!}") { - result2 = "!}"; - advance(pos, 2); + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"!}\""); - } + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - reportFailures--; - if (result2 === null) { - result2 = ""; + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c83(s5); + s3 = s4; } else { - result2 = null; - pos = clone(pos4); + peg$currPos = s3; + s3 = peg$c3; } - if (result2 !== null) { - if (input.length > pos.offset) { - result3 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = clone(pos3); - } + } 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 { - result2 = null; - pos = clone(pos3); - } - if (result2 !== null) { - result2 = (function(offset, line, column, c) {return c})(pos2.offset, pos2.line, pos2.column, result2[1]); + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } } - if (result2 === null) { - pos = clone(pos2); + peg$silentFails--; + if (s5 === peg$FAILED) { + s4 = peg$c6; + } else { + peg$currPos = s4; + s4 = peg$c3; } - while (result2 !== null) { - result1.push(result2); - pos2 = clone(pos); - pos3 = clone(pos); - pos4 = clone(pos); - reportFailures++; - if (input.substr(pos.offset, 2) === "!}") { - result2 = "!}"; - advance(pos, 2); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"!}\""); - } - } - reportFailures--; - if (result2 === null) { - result2 = ""; + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; } else { - result2 = null; - pos = clone(pos4); + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - if (result2 !== null) { - if (input.length > pos.offset) { - result3 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = clone(pos3); - } + if (s5 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c83(s5); + s3 = s4; } else { - result2 = null; - pos = clone(pos3); - } - if (result2 !== null) { - result2 = (function(offset, line, column, c) {return c})(pos2.offset, pos2.line, pos2.column, result2[1]); - } - if (result2 === null) { - pos = clone(pos2); + peg$currPos = s3; + s3 = peg$c3; } + } else { + peg$currPos = s3; + s3 = peg$c3; } - if (result1 !== null) { - if (input.substr(pos.offset, 2) === "!}") { - result2 = "!}"; - advance(pos, 2); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"!}\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = clone(pos1); - } + } + 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 { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos1); + peg$currPos = s0; + s0 = peg$c3; } - if (result0 !== null) { - result0 = (function(offset, line, column, c) { return ["comment", c.join('')].concat([['line', line], ['col', column]]) })(pos0.offset, pos0.line, pos0.column, result0[1]); - } - if (result0 === null) { - pos = clone(pos0); - } - reportFailures--; - if (reportFailures === 0 && result0 === null) { - matchFailed("comment"); - } - return result0; - } - - function parse_tag() { - var result0, result1, result2, result3, result4, result5, result6, result7; - var pos0, pos1, pos2; - - pos0 = clone(pos); - result0 = parse_ld(); - if (result0 !== null) { - result1 = []; - result2 = parse_ws(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_ws(); - } - if (result1 !== null) { - if (/^[#?^><+%:@\/~%]/.test(input.charAt(pos.offset))) { - result2 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[#?^><+%:@\\/~%]"); - } - } - if (result2 !== null) { - result3 = []; - result4 = parse_ws(); - while (result4 !== null) { - result3.push(result4); - result4 = parse_ws(); + } 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 (result3 !== null) { - pos1 = clone(pos); - pos2 = clone(pos); - reportFailures++; - result5 = parse_rd(); - reportFailures--; - if (result5 === null) { - result5 = ""; + if (s7 !== peg$FAILED) { + s8 = peg$currPos; + peg$silentFails++; + s9 = peg$parseeol(); + peg$silentFails--; + if (s9 === peg$FAILED) { + s8 = peg$c6; } else { - result5 = null; - pos = clone(pos2); + peg$currPos = s8; + s8 = peg$c3; } - if (result5 !== null) { - pos2 = clone(pos); - reportFailures++; - result6 = parse_eol(); - reportFailures--; - if (result6 === null) { - result6 = ""; + if (s8 !== peg$FAILED) { + if (input.length > peg$currPos) { + s9 = input.charAt(peg$currPos); + peg$currPos++; } else { - result6 = null; - pos = clone(pos2); + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - if (result6 !== null) { - if (input.length > pos.offset) { - result7 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result7 !== null) { - result5 = [result5, result6, result7]; - } else { - result5 = null; - pos = clone(pos1); - } + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; } else { - result5 = null; - pos = clone(pos1); + peg$currPos = s6; + s6 = peg$c3; } } else { - result5 = null; - pos = clone(pos1); + peg$currPos = s6; + s6 = peg$c3; } - if (result5 !== null) { - result4 = []; - while (result5 !== null) { - result4.push(result5); - pos1 = clone(pos); - pos2 = clone(pos); - reportFailures++; - result5 = parse_rd(); - reportFailures--; - if (result5 === null) { - result5 = ""; + } 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 { - result5 = null; - pos = clone(pos2); + peg$currPos = s8; + s8 = peg$c3; } - if (result5 !== null) { - pos2 = clone(pos); - reportFailures++; - result6 = parse_eol(); - reportFailures--; - if (result6 === null) { - result6 = ""; + if (s8 !== peg$FAILED) { + if (input.length > peg$currPos) { + s9 = input.charAt(peg$currPos); + peg$currPos++; } else { - result6 = null; - pos = clone(pos2); + s9 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } } - if (result6 !== null) { - if (input.length > pos.offset) { - result7 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("any character"); - } - } - if (result7 !== null) { - result5 = [result5, result6, result7]; - } else { - result5 = null; - pos = clone(pos1); - } + if (s9 !== peg$FAILED) { + s7 = [s7, s8, s9]; + s6 = s7; } else { - result5 = null; - pos = clone(pos1); + peg$currPos = s6; + s6 = peg$c3; } } else { - result5 = null; - pos = clone(pos1); + peg$currPos = s6; + s6 = peg$c3; } + } else { + peg$currPos = s6; + s6 = peg$c3; } - } else { - result4 = null; } - if (result4 !== null) { - result5 = []; - result6 = parse_ws(); - while (result6 !== null) { - result5.push(result6); - result6 = parse_ws(); - } - if (result5 !== null) { - result6 = parse_rd(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = clone(pos0); - } + } 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 { - result0 = null; - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos0); + peg$currPos = s0; + s0 = peg$c3; } } else { - result0 = null; - pos = clone(pos0); - } - } else { - result0 = null; - pos = clone(pos0); - } - if (result0 === null) { - result0 = parse_reference(); - } - return result0; - } - - function parse_ld() { - var result0; - - if (input.charCodeAt(pos.offset) === 123) { - result0 = "{"; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"{\""); - } - } - return result0; - } - - function parse_rd() { - var result0; - - if (input.charCodeAt(pos.offset) === 125) { - result0 = "}"; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"}\""); + peg$currPos = s0; + s0 = peg$c3; } - } - return result0; - } - - function parse_lb() { - var result0; - - if (input.charCodeAt(pos.offset) === 91) { - result0 = "["; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - return result0; - } - - function parse_rb() { - var result0; - - if (input.charCodeAt(pos.offset) === 93) { - result0 = "]"; - advance(pos, 1); } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } + peg$currPos = s0; + s0 = peg$c3; } - return result0; - } - - function parse_eol() { - var result0; - - if (input.charCodeAt(pos.offset) === 10) { - result0 = "\n"; - advance(pos, 1); + } 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 { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\n\""); - } + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c118); } } - if (result0 === null) { - if (input.substr(pos.offset, 2) === "\r\n") { - result0 = "\r\n"; - advance(pos, 2); + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 13) { + s0 = peg$c119; + peg$currPos++; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\r\\n\""); - } + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c120); } } - if (result0 === null) { - if (input.charCodeAt(pos.offset) === 13) { - result0 = "\r"; - advance(pos, 1); + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 8232) { + s0 = peg$c121; + peg$currPos++; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\r\""); - } + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c122); } } - if (result0 === null) { - if (input.charCodeAt(pos.offset) === 8232) { - result0 = "\u2028"; - advance(pos, 1); + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 8233) { + s0 = peg$c123; + peg$currPos++; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\u2028\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos.offset) === 8233) { - result0 = "\u2029"; - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\u2029\""); - } - } + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c124); } } } } } - return result0; - } - - function parse_ws() { - var result0; - - if (/^[\t\x0B\f \xA0\uFEFF]/.test(input.charAt(pos.offset))) { - result0 = input.charAt(pos.offset); - advance(pos, 1); - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\t\\x0B\\f \\xA0\\uFEFF]"); - } - } - if (result0 === null) { - result0 = parse_eol(); - } - return result0; } - - - function cleanupExpected(expected) { - expected.sort(); - - var lastExpected = null; - var cleanExpected = []; - for (var i = 0; i < expected.length; i++) { - if (expected[i] !== lastExpected) { - cleanExpected.push(expected[i]); - lastExpected = expected[i]; - } - } - return cleanExpected; - } - - - - var result = parseFunctions[startRule](); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos.offset === input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos.offset < input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos.offset === 0| - * - |rightmostFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos.offset !== input.length) { - var offset = Math.max(pos.offset, rightmostFailuresPos.offset); - var found = offset < input.length ? input.charAt(offset) : null; - var errorPosition = pos.offset > rightmostFailuresPos.offset ? pos : rightmostFailuresPos; - - throw new parser.SyntaxError( - cleanupExpected(rightmostFailuresExpected), - found, - offset, - 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(expected, found, offset, line, column) { - function buildMessage(expected, found) { - var expectedHumanized, foundHumanized; - - switch (expected.length) { - case 0: - expectedHumanized = "end of input"; - break; - case 1: - expectedHumanized = expected[0]; - break; - default: - expectedHumanized = expected.slice(0, expected.length - 1).join(", ") - + " or " - + expected[expected.length - 1]; - } - - foundHumanized = found ? quote(found) : "end of input"; - - return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; + + return s0; } - - this.name = "SyntaxError"; - this.expected = expected; - this.found = found; - this.message = buildMessage(expected, found); - this.offset = offset; - this.line = line; - this.column = column; + + 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 }; - - result.SyntaxError.prototype = Error.prototype; - - return result; })(); // expose parser methods diff --git a/dist/dust-full.min.js b/dist/dust-full.min.js index 8551e2a1..cd5d6a72 100644 --- a/dist/dust-full.min.js +++ b/dist/dust-full.min.js @@ -1,5 +1,5 @@ -/*! Dust - Asynchronous Templating - v2.4.1 +/*! 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){return dust.log(a,ERROR)}}:(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);return this.next=c,this.flushable=!0,a(c),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&&(a=a.apply(b.current(),[this,b,c,d]),a instanceof Chunk))return a;var e=c.block,f=c["else"];if(d&&(b=b.push(d)),dust.isArray(a)){if(e){var g=a.length,h=this;if(g>0){b.stack.head&&(b.stack.head.$len=g);for(var i=0;g>i;i++)b.stack.head&&(b.stack.head.$idx=i),h=e(h,b.push(a[i],i,g));return b.stack.head&&(b.stack.head.$idx=void 0,b.stack.head.$len=void 0),h}if(f)return f(this,b)}}else if(a===!0){if(e)return e(this,b)}else if(a||0===a){if(e)return e(this,b.push(a))}else if(f)return f(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;try{return dust.helpers[a]?dust.helpers[a](e,b,c,d):(dust.log("Invalid helper ["+a+"]",WARN),e)}catch(f){return e.setError(f),e}},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,GT=/>/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 b(a){return'"'+a.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-\x1F\x80-\uFFFF]/g,escape)+'"'}var c={parse:function(c,d){function e(a){var b={};for(var c in a)b[c]=a[c];return b}function f(a,b){for(var d=a.offset+b,e=a.offset;d>e;e++){var f=c.charAt(e);"\n"===f?(a.seenCR||a.line++,a.column=1,a.seenCR=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(a.line++,a.column=1,a.seenCR=!0):(a.column++,a.seenCR=!1)}a.offset+=b}function g(a){R.offset<T.offset||(R.offset>T.offset&&(T=e(R),U=[]),U.push(a))}function h(){var a,b,c;for(c=e(R),a=[],b=i();null!==b;)a.push(b),b=i();return null!==a&&(a=function(a,b,c,d){return["body"].concat(d).concat([["line",b],["col",c]])}(c.offset,c.line,c.column,a)),null===a&&(R=e(c)),a}function i(){var a;return a=G(),null===a&&(a=H(),null===a&&(a=j(),null===a&&(a=q(),null===a&&(a=s(),null===a&&(a=p(),null===a&&(a=D())))))),a}function j(){var a,b,d,i,j,m,n,p,q;if(S++,p=e(R),q=e(R),a=k(),null!==a){for(b=[],d=O();null!==d;)b.push(d),d=O();null!==b?(d=K(),null!==d?(i=h(),null!==i?(j=o(),null!==j?(m=l(),m=null!==m?m:"",null!==m?(n=function(a,b,c,d,e,f,g){if(!g||d[1].text!==g.text)throw new Error("Expected end tag for "+d[1].text+" but it was not found. At line : "+b+", column : "+c);return!0}(R.offset,R.line,R.column,a,i,j,m)?"":null,null!==n?a=[a,b,d,i,j,m,n]:(a=null,R=e(q))):(a=null,R=e(q))):(a=null,R=e(q))):(a=null,R=e(q))):(a=null,R=e(q))):(a=null,R=e(q))}else a=null,R=e(q);if(null!==a&&(a=function(a,b,c,d,e,f){return f.push(["param",["literal","block"],e]),d.push(f),d.concat([["line",b],["col",c]])}(p.offset,p.line,p.column,a[0],a[3],a[4],a[5])),null===a&&(R=e(p)),null===a){if(p=e(R),q=e(R),a=k(),null!==a){for(b=[],d=O();null!==d;)b.push(d),d=O();null!==b?(47===c.charCodeAt(R.offset)?(d="/",f(R,1)):(d=null,0===S&&g('"/"')),null!==d?(i=K(),null!==i?a=[a,b,d,i]:(a=null,R=e(q))):(a=null,R=e(q))):(a=null,R=e(q))}else a=null,R=e(q);null!==a&&(a=function(a,b,c,d){return d.push(["bodies"]),d.concat([["line",b],["col",c]])}(p.offset,p.line,p.column,a[0])),null===a&&(R=e(p))}return S--,0===S&&null===a&&g("section"),a}function k(){var a,b,d,h,i,j,k,l;if(k=e(R),l=e(R),a=J(),null!==a)if(/^[#?^<+@%]/.test(c.charAt(R.offset))?(b=c.charAt(R.offset),f(R,1)):(b=null,0===S&&g("[#?^<+@%]")),null!==b){for(d=[],h=O();null!==h;)d.push(h),h=O();null!==d?(h=t(),null!==h?(i=m(),null!==i?(j=n(),null!==j?a=[a,b,d,h,i,j]:(a=null,R=e(l))):(a=null,R=e(l))):(a=null,R=e(l))):(a=null,R=e(l))}else a=null,R=e(l);else a=null,R=e(l);return null!==a&&(a=function(a,b,c,d,e,f,g){return[d,e,f,g]}(k.offset,k.line,k.column,a[1],a[3],a[4],a[5])),null===a&&(R=e(k)),a}function l(){var a,b,d,h,i,j,k,l;if(S++,k=e(R),l=e(R),a=J(),null!==a)if(47===c.charCodeAt(R.offset)?(b="/",f(R,1)):(b=null,0===S&&g('"/"')),null!==b){for(d=[],h=O();null!==h;)d.push(h),h=O();if(null!==d)if(h=t(),null!==h){for(i=[],j=O();null!==j;)i.push(j),j=O();null!==i?(j=K(),null!==j?a=[a,b,d,h,i,j]:(a=null,R=e(l))):(a=null,R=e(l))}else a=null,R=e(l);else a=null,R=e(l)}else a=null,R=e(l);else a=null,R=e(l);return null!==a&&(a=function(a,b,c,d){return d}(k.offset,k.line,k.column,a[3])),null===a&&(R=e(k)),S--,0===S&&null===a&&g("end tag"),a}function m(){var a,b,d,h,i;return d=e(R),h=e(R),i=e(R),58===c.charCodeAt(R.offset)?(a=":",f(R,1)):(a=null,0===S&&g('":"')),null!==a?(b=t(),null!==b?a=[a,b]:(a=null,R=e(i))):(a=null,R=e(i)),null!==a&&(a=function(a,b,c,d){return d}(h.offset,h.line,h.column,a[1])),null===a&&(R=e(h)),a=null!==a?a:"",null!==a&&(a=function(a,b,c,d){return d?["context",d]:["context"]}(d.offset,d.line,d.column,a)),null===a&&(R=e(d)),a}function n(){var a,b,d,h,i,j,k,l;if(S++,j=e(R),a=[],k=e(R),l=e(R),d=O(),null!==d)for(b=[];null!==d;)b.push(d),d=O();else b=null;for(null!==b?(d=y(),null!==d?(61===c.charCodeAt(R.offset)?(h="=",f(R,1)):(h=null,0===S&&g('"="')),null!==h?(i=u(),null===i&&(i=t(),null===i&&(i=B())),null!==i?b=[b,d,h,i]:(b=null,R=e(l))):(b=null,R=e(l))):(b=null,R=e(l))):(b=null,R=e(l)),null!==b&&(b=function(a,b,c,d,e){return["param",["literal",d],e]}(k.offset,k.line,k.column,b[1],b[3])),null===b&&(R=e(k));null!==b;){if(a.push(b),k=e(R),l=e(R),d=O(),null!==d)for(b=[];null!==d;)b.push(d),d=O();else b=null;null!==b?(d=y(),null!==d?(61===c.charCodeAt(R.offset)?(h="=",f(R,1)):(h=null,0===S&&g('"="')),null!==h?(i=u(),null===i&&(i=t(),null===i&&(i=B())),null!==i?b=[b,d,h,i]:(b=null,R=e(l))):(b=null,R=e(l))):(b=null,R=e(l))):(b=null,R=e(l)),null!==b&&(b=function(a,b,c,d,e){return["param",["literal",d],e]}(k.offset,k.line,k.column,b[1],b[3])),null===b&&(R=e(k))}return null!==a&&(a=function(a,b,c,d){return["params"].concat(d)}(j.offset,j.line,j.column,a)),null===a&&(R=e(j)),S--,0===S&&null===a&&g("params"),a}function o(){var a,b,d,i,j,k,l,m,n;for(S++,l=e(R),a=[],m=e(R),n=e(R),b=J(),null!==b?(58===c.charCodeAt(R.offset)?(d=":",f(R,1)):(d=null,0===S&&g('":"')),null!==d?(i=y(),null!==i?(j=K(),null!==j?(k=h(),null!==k?b=[b,d,i,j,k]:(b=null,R=e(n))):(b=null,R=e(n))):(b=null,R=e(n))):(b=null,R=e(n))):(b=null,R=e(n)),null!==b&&(b=function(a,b,c,d,e){return["param",["literal",d],e]}(m.offset,m.line,m.column,b[2],b[4])),null===b&&(R=e(m));null!==b;)a.push(b),m=e(R),n=e(R),b=J(),null!==b?(58===c.charCodeAt(R.offset)?(d=":",f(R,1)):(d=null,0===S&&g('":"')),null!==d?(i=y(),null!==i?(j=K(),null!==j?(k=h(),null!==k?b=[b,d,i,j,k]:(b=null,R=e(n))):(b=null,R=e(n))):(b=null,R=e(n))):(b=null,R=e(n))):(b=null,R=e(n)),null!==b&&(b=function(a,b,c,d,e){return["param",["literal",d],e]}(m.offset,m.line,m.column,b[2],b[4])),null===b&&(R=e(m));return null!==a&&(a=function(a,b,c,d){return["bodies"].concat(d)}(l.offset,l.line,l.column,a)),null===a&&(R=e(l)),S--,0===S&&null===a&&g("bodies"),a}function p(){var a,b,c,d,f,h;return S++,f=e(R),h=e(R),a=J(),null!==a?(b=t(),null!==b?(c=r(),null!==c?(d=K(),null!==d?a=[a,b,c,d]:(a=null,R=e(h))):(a=null,R=e(h))):(a=null,R=e(h))):(a=null,R=e(h)),null!==a&&(a=function(a,b,c,d,e){return["reference",d,e].concat([["line",b],["col",c]])}(f.offset,f.line,f.column,a[1],a[2])),null===a&&(R=e(f)),S--,0===S&&null===a&&g("reference"),a}function q(){var a,b,d,h,i,j,k,l,o,p,q,r;if(S++,p=e(R),q=e(R),a=J(),null!==a)if(62===c.charCodeAt(R.offset)?(b=">",f(R,1)):(b=null,0===S&&g('">"')),null===b&&(43===c.charCodeAt(R.offset)?(b="+",f(R,1)):(b=null,0===S&&g('"+"'))),null!==b){for(d=[],h=O();null!==h;)d.push(h),h=O();if(null!==d)if(r=e(R),h=y(),null!==h&&(h=function(a,b,c,d){return["literal",d]}(r.offset,r.line,r.column,h)),null===h&&(R=e(r)),null===h&&(h=B()),null!==h)if(i=m(),null!==i)if(j=n(),null!==j){for(k=[],l=O();null!==l;)k.push(l),l=O();null!==k?(47===c.charCodeAt(R.offset)?(l="/",f(R,1)):(l=null,0===S&&g('"/"')),null!==l?(o=K(),null!==o?a=[a,b,d,h,i,j,k,l,o]:(a=null,R=e(q))):(a=null,R=e(q))):(a=null,R=e(q))}else a=null,R=e(q);else a=null,R=e(q);else a=null,R=e(q);else a=null,R=e(q)}else a=null,R=e(q);else a=null,R=e(q);return null!==a&&(a=function(a,b,c,d,e,f,g){var h=">"===d?"partial":d;return[h,e,f,g].concat([["line",b],["col",c]])}(p.offset,p.line,p.column,a[1],a[3],a[4],a[5])),null===a&&(R=e(p)),S--,0===S&&null===a&&g("partial"),a}function r(){var a,b,d,h,i,j;for(S++,h=e(R),a=[],i=e(R),j=e(R),124===c.charCodeAt(R.offset)?(b="|",f(R,1)):(b=null,0===S&&g('"|"')),null!==b?(d=y(),null!==d?b=[b,d]:(b=null,R=e(j))):(b=null,R=e(j)),null!==b&&(b=function(a,b,c,d){return d}(i.offset,i.line,i.column,b[1])),null===b&&(R=e(i));null!==b;)a.push(b),i=e(R),j=e(R),124===c.charCodeAt(R.offset)?(b="|",f(R,1)):(b=null,0===S&&g('"|"')),null!==b?(d=y(),null!==d?b=[b,d]:(b=null,R=e(j))):(b=null,R=e(j)),null!==b&&(b=function(a,b,c,d){return d}(i.offset,i.line,i.column,b[1])),null===b&&(R=e(i));return null!==a&&(a=function(a,b,c,d){return["filters"].concat(d)}(h.offset,h.line,h.column,a)),null===a&&(R=e(h)),S--,0===S&&null===a&&g("filters"),a}function s(){var a,b,d,h,i,j;return S++,i=e(R),j=e(R),a=J(),null!==a?(126===c.charCodeAt(R.offset)?(b="~",f(R,1)):(b=null,0===S&&g('"~"')),null!==b?(d=y(),null!==d?(h=K(),null!==h?a=[a,b,d,h]:(a=null,R=e(j))):(a=null,R=e(j))):(a=null,R=e(j))):(a=null,R=e(j)),null!==a&&(a=function(a,b,c,d){return["special",d].concat([["line",b],["col",c]])}(i.offset,i.line,i.column,a[2])),null===a&&(R=e(i)),S--,0===S&&null===a&&g("special"),a}function t(){var a,b;return S++,b=e(R),a=x(),null!==a&&(a=function(a,b,c,d){var e=["path"].concat(d);return e.text=d[1].join("."),e}(b.offset,b.line,b.column,a)),null===a&&(R=e(b)),null===a&&(b=e(R),a=y(),null!==a&&(a=function(a,b,c,d){var e=["key",d];return e.text=d,e}(b.offset,b.line,b.column,a)),null===a&&(R=e(b))),S--,0===S&&null===a&&g("identifier"),a}function u(){var a,b;return S++,b=e(R),a=v(),null===a&&(a=w()),null!==a&&(a=function(a,b,c,d){return["literal",d]}(b.offset,b.line,b.column,a)),null===a&&(R=e(b)),S--,0===S&&null===a&&g("number"),a}function v(){var a,b,d,h,i,j;if(S++,i=e(R),j=e(R),a=w(),null!==a)if(46===c.charCodeAt(R.offset)?(b=".",f(R,1)):(b=null,0===S&&g('"."')),null!==b){if(h=w(),null!==h)for(d=[];null!==h;)d.push(h),h=w();else d=null;null!==d?a=[a,b,d]:(a=null,R=e(j))}else a=null,R=e(j);else a=null,R=e(j);return null!==a&&(a=function(a,b,c,d,e){return parseFloat(d+"."+e.join(""))}(i.offset,i.line,i.column,a[0],a[2])),null===a&&(R=e(i)),S--,0===S&&null===a&&g("float"),a}function w(){var a,b,d;if(S++,d=e(R),/^[0-9]/.test(c.charAt(R.offset))?(b=c.charAt(R.offset),f(R,1)):(b=null,0===S&&g("[0-9]")),null!==b)for(a=[];null!==b;)a.push(b),/^[0-9]/.test(c.charAt(R.offset))?(b=c.charAt(R.offset),f(R,1)):(b=null,0===S&&g("[0-9]"));else a=null;return null!==a&&(a=function(a,b,c,d){return parseInt(d.join(""),10)}(d.offset,d.line,d.column,a)),null===a&&(R=e(d)),S--,0===S&&null===a&&g("integer"),a}function x(){var a,b,d,h,i;if(S++,h=e(R),i=e(R),a=y(),a=null!==a?a:"",null!==a){if(d=A(),null===d&&(d=z()),null!==d)for(b=[];null!==d;)b.push(d),d=A(),null===d&&(d=z());else b=null;null!==b?a=[a,b]:(a=null,R=e(i))}else a=null,R=e(i);if(null!==a&&(a=function(a,b,c,d,e){return e=e[0],d&&e?(e.unshift(d),[!1,e].concat([["line",b],["col",c]])):[!0,e].concat([["line",b],["col",c]])}(h.offset,h.line,h.column,a[0],a[1])),null===a&&(R=e(h)),null===a){if(h=e(R),i=e(R),46===c.charCodeAt(R.offset)?(a=".",f(R,1)):(a=null,0===S&&g('"."')),null!==a){for(b=[],d=A(),null===d&&(d=z());null!==d;)b.push(d),d=A(),null===d&&(d=z());null!==b?a=[a,b]:(a=null,R=e(i))}else a=null,R=e(i);null!==a&&(a=function(a,b,c,d){return d.length>0?[!0,d[0]].concat([["line",b],["col",c]]):[!0,[]].concat([["line",b],["col",c]])}(h.offset,h.line,h.column,a[1])),null===a&&(R=e(h))}return S--,0===S&&null===a&&g("path"),a}function y(){var a,b,d,h,i;if(S++,h=e(R),i=e(R),/^[a-zA-Z_$]/.test(c.charAt(R.offset))?(a=c.charAt(R.offset),f(R,1)):(a=null,0===S&&g("[a-zA-Z_$]")),null!==a){for(b=[],/^[0-9a-zA-Z_$\-]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g("[0-9a-zA-Z_$\\-]"));null!==d;)b.push(d),/^[0-9a-zA-Z_$\-]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g("[0-9a-zA-Z_$\\-]"));null!==b?a=[a,b]:(a=null,R=e(i))}else a=null,R=e(i);return null!==a&&(a=function(a,b,c,d,e){return d+e.join("")}(h.offset,h.line,h.column,a[0],a[1])),null===a&&(R=e(h)),S--,0===S&&null===a&&g("key"),a}function z(){var a,b,d,h,i,j,k,l;if(S++,h=e(R),i=e(R),j=e(R),k=e(R),a=L(),null!==a){if(l=e(R),/^[0-9]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g("[0-9]")),null!==d)for(b=[];null!==d;)b.push(d),/^[0-9]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g("[0-9]"));else b=null;null!==b&&(b=function(a,b,c,d){return d.join("")}(l.offset,l.line,l.column,b)),null===b&&(R=e(l)),null===b&&(b=t()),null!==b?(d=M(),null!==d?a=[a,b,d]:(a=null,R=e(k))):(a=null,R=e(k))}else a=null,R=e(k);return null!==a&&(a=function(a,b,c,d){return d}(j.offset,j.line,j.column,a[1])),null===a&&(R=e(j)),null!==a?(b=A(),b=null!==b?b:"",null!==b?a=[a,b]:(a=null,R=e(i))):(a=null,R=e(i)),null!==a&&(a=function(a,b,c,d,e){return e?e.unshift(d):e=[d],e}(h.offset,h.line,h.column,a[0],a[1])),null===a&&(R=e(h)),S--,0===S&&null===a&&g("array"),a}function A(){var a,b,d,h,i,j,k;if(S++,h=e(R),i=e(R),j=e(R),k=e(R),46===c.charCodeAt(R.offset)?(b=".",f(R,1)):(b=null,0===S&&g('"."')),null!==b?(d=y(),null!==d?b=[b,d]:(b=null,R=e(k))):(b=null,R=e(k)),null!==b&&(b=function(a,b,c,d){return d}(j.offset,j.line,j.column,b[1])),null===b&&(R=e(j)),null!==b)for(a=[];null!==b;)a.push(b),j=e(R),k=e(R),46===c.charCodeAt(R.offset)?(b=".",f(R,1)):(b=null,0===S&&g('"."')),null!==b?(d=y(),null!==d?b=[b,d]:(b=null,R=e(k))):(b=null,R=e(k)),null!==b&&(b=function(a,b,c,d){return d}(j.offset,j.line,j.column,b[1])),null===b&&(R=e(j));else a=null;return null!==a?(b=z(),b=null!==b?b:"",null!==b?a=[a,b]:(a=null,R=e(i))):(a=null,R=e(i)),null!==a&&(a=function(a,b,c,d,e){return e?d.concat(e):d}(h.offset,h.line,h.column,a[0],a[1])),null===a&&(R=e(h)),S--,0===S&&null===a&&g("array_part"),a}function B(){var a,b,d,h,i;if(S++,h=e(R),i=e(R),34===c.charCodeAt(R.offset)?(a='"',f(R,1)):(a=null,0===S&&g('"\\""')),null!==a?(34===c.charCodeAt(R.offset)?(b='"',f(R,1)):(b=null,0===S&&g('"\\""')),null!==b?a=[a,b]:(a=null,R=e(i))):(a=null,R=e(i)),null!==a&&(a=function(a,b,c){return["literal",""].concat([["line",b],["col",c]])}(h.offset,h.line,h.column)),null===a&&(R=e(h)),null===a&&(h=e(R),i=e(R),34===c.charCodeAt(R.offset)?(a='"',f(R,1)):(a=null,0===S&&g('"\\""')),null!==a?(b=E(),null!==b?(34===c.charCodeAt(R.offset)?(d='"',f(R,1)):(d=null,0===S&&g('"\\""')),null!==d?a=[a,b,d]:(a=null,R=e(i))):(a=null,R=e(i))):(a=null,R=e(i)),null!==a&&(a=function(a,b,c,d){return["literal",d].concat([["line",b],["col",c]])}(h.offset,h.line,h.column,a[1])),null===a&&(R=e(h)),null===a)){if(h=e(R),i=e(R),34===c.charCodeAt(R.offset)?(a='"',f(R,1)):(a=null,0===S&&g('"\\""')),null!==a){if(d=C(),null!==d)for(b=[];null!==d;)b.push(d),d=C();else b=null;null!==b?(34===c.charCodeAt(R.offset)?(d='"',f(R,1)):(d=null,0===S&&g('"\\""')),null!==d?a=[a,b,d]:(a=null,R=e(i))):(a=null,R=e(i))}else a=null,R=e(i);null!==a&&(a=function(a,b,c,d){return["body"].concat(d).concat([["line",b],["col",c]])}(h.offset,h.line,h.column,a[1])),null===a&&(R=e(h))}return S--,0===S&&null===a&&g("inline"),a}function C(){var a,b;return a=s(),null===a&&(a=p(),null===a&&(b=e(R),a=E(),null!==a&&(a=function(a,b,c,d){return["buffer",d]}(b.offset,b.line,b.column,a)),null===a&&(R=e(b)))),a}function D(){var a,b,d,h,i,j,k,l,m,n;if(S++,k=e(R),l=e(R),a=N(),null!==a){for(b=[],d=O();null!==d;)b.push(d),d=O();null!==b?a=[a,b]:(a=null,R=e(l))}else a=null,R=e(l);if(null!==a&&(a=function(a,b,c,d,e){return["format",d,e.join("")].concat([["line",b],["col",c]])}(k.offset,k.line,k.column,a[0],a[1])),null===a&&(R=e(k)),null===a){if(k=e(R),l=e(R),m=e(R),n=e(R),S++,b=I(),S--,null===b?b="":(b=null,R=e(n)),null!==b?(n=e(R),S++,d=G(),S--,null===d?d="":(d=null,R=e(n)),null!==d?(n=e(R),S++,h=H(),S--,null===h?h="":(h=null,R=e(n)),null!==h?(n=e(R),S++,i=N(),S--,null===i?i="":(i=null,R=e(n)),null!==i?(c.length>R.offset?(j=c.charAt(R.offset),f(R,1)):(j=null,0===S&&g("any character")),null!==j?b=[b,d,h,i,j]:(b=null,R=e(m))):(b=null,R=e(m))):(b=null,R=e(m))):(b=null,R=e(m))):(b=null,R=e(m)),null!==b&&(b=function(a,b,c,d){return d}(l.offset,l.line,l.column,b[4])),null===b&&(R=e(l)),null!==b)for(a=[];null!==b;)a.push(b),l=e(R),m=e(R),n=e(R),S++,b=I(),S--,null===b?b="":(b=null,R=e(n)),null!==b?(n=e(R),S++,d=G(),S--,null===d?d="":(d=null,R=e(n)),null!==d?(n=e(R),S++,h=H(),S--,null===h?h="":(h=null,R=e(n)),null!==h?(n=e(R),S++,i=N(),S--,null===i?i="":(i=null,R=e(n)),null!==i?(c.length>R.offset?(j=c.charAt(R.offset),f(R,1)):(j=null,0===S&&g("any character")),null!==j?b=[b,d,h,i,j]:(b=null,R=e(m))):(b=null,R=e(m))):(b=null,R=e(m))):(b=null,R=e(m))):(b=null,R=e(m)),null!==b&&(b=function(a,b,c,d){return d}(l.offset,l.line,l.column,b[4])),null===b&&(R=e(l));else a=null;null!==a&&(a=function(a,b,c,d){return["buffer",d.join("")].concat([["line",b],["col",c]])}(k.offset,k.line,k.column,a)),null===a&&(R=e(k))}return S--,0===S&&null===a&&g("buffer"),a}function E(){var a,b,d,h,i,j,k;if(S++,h=e(R),i=e(R),j=e(R),k=e(R),S++,b=I(),S--,null===b?b="":(b=null,R=e(k)),null!==b?(d=F(),null===d&&(/^[^"]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g('[^"]'))),null!==d?b=[b,d]:(b=null,R=e(j))):(b=null,R=e(j)),null!==b&&(b=function(a,b,c,d){return d}(i.offset,i.line,i.column,b[1])),null===b&&(R=e(i)),null!==b)for(a=[];null!==b;)a.push(b),i=e(R),j=e(R),k=e(R),S++,b=I(),S--,null===b?b="":(b=null,R=e(k)),null!==b?(d=F(),null===d&&(/^[^"]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g('[^"]'))),null!==d?b=[b,d]:(b=null,R=e(j))):(b=null,R=e(j)),null!==b&&(b=function(a,b,c,d){return d}(i.offset,i.line,i.column,b[1])),null===b&&(R=e(i));else a=null;return null!==a&&(a=function(a,b,c,d){return d.join("")}(h.offset,h.line,h.column,a)),null===a&&(R=e(h)),S--,0===S&&null===a&&g("literal"),a}function F(){var a,b;return b=e(R),'\\"'===c.substr(R.offset,2)?(a='\\"',f(R,2)):(a=null,0===S&&g('"\\\\\\""')),null!==a&&(a=function(){return'"'}(b.offset,b.line,b.column)),null===a&&(R=e(b)),a}function G(){var a,b,d,h,i,j,k,l,m;if(S++,i=e(R),j=e(R),"{`"===c.substr(R.offset,2)?(a="{`",f(R,2)):(a=null,0===S&&g('"{`"')),null!==a){for(b=[],k=e(R),l=e(R),m=e(R),S++,"`}"===c.substr(R.offset,2)?(d="`}",f(R,2)):(d=null,0===S&&g('"`}"')),S--,null===d?d="":(d=null,R=e(m)),null!==d?(c.length>R.offset?(h=c.charAt(R.offset),f(R,1)):(h=null,0===S&&g("any character")),null!==h?d=[d,h]:(d=null,R=e(l))):(d=null,R=e(l)),null!==d&&(d=function(a,b,c,d){return d}(k.offset,k.line,k.column,d[1])),null===d&&(R=e(k));null!==d;)b.push(d),k=e(R),l=e(R),m=e(R),S++,"`}"===c.substr(R.offset,2)?(d="`}",f(R,2)):(d=null,0===S&&g('"`}"')),S--,null===d?d="":(d=null,R=e(m)),null!==d?(c.length>R.offset?(h=c.charAt(R.offset),f(R,1)):(h=null,0===S&&g("any character")),null!==h?d=[d,h]:(d=null,R=e(l))):(d=null,R=e(l)),null!==d&&(d=function(a,b,c,d){return d}(k.offset,k.line,k.column,d[1])),null===d&&(R=e(k));null!==b?("`}"===c.substr(R.offset,2)?(d="`}",f(R,2)):(d=null,0===S&&g('"`}"')),null!==d?a=[a,b,d]:(a=null,R=e(j))):(a=null,R=e(j))}else a=null,R=e(j);return null!==a&&(a=function(a,b,c,d){return["raw",d.join("")].concat([["line",b],["col",c]])}(i.offset,i.line,i.column,a[1])),null===a&&(R=e(i)),S--,0===S&&null===a&&g("raw"),a}function H(){var a,b,d,h,i,j,k,l,m;if(S++,i=e(R),j=e(R),"{!"===c.substr(R.offset,2)?(a="{!",f(R,2)):(a=null,0===S&&g('"{!"')),null!==a){for(b=[],k=e(R),l=e(R),m=e(R),S++,"!}"===c.substr(R.offset,2)?(d="!}",f(R,2)):(d=null,0===S&&g('"!}"')),S--,null===d?d="":(d=null,R=e(m)),null!==d?(c.length>R.offset?(h=c.charAt(R.offset),f(R,1)):(h=null,0===S&&g("any character")),null!==h?d=[d,h]:(d=null,R=e(l))):(d=null,R=e(l)),null!==d&&(d=function(a,b,c,d){return d}(k.offset,k.line,k.column,d[1])),null===d&&(R=e(k));null!==d;)b.push(d),k=e(R),l=e(R),m=e(R),S++,"!}"===c.substr(R.offset,2)?(d="!}",f(R,2)):(d=null,0===S&&g('"!}"')),S--,null===d?d="":(d=null,R=e(m)),null!==d?(c.length>R.offset?(h=c.charAt(R.offset),f(R,1)):(h=null,0===S&&g("any character")),null!==h?d=[d,h]:(d=null,R=e(l))):(d=null,R=e(l)),null!==d&&(d=function(a,b,c,d){return d}(k.offset,k.line,k.column,d[1])),null===d&&(R=e(k));null!==b?("!}"===c.substr(R.offset,2)?(d="!}",f(R,2)):(d=null,0===S&&g('"!}"')),null!==d?a=[a,b,d]:(a=null,R=e(j))):(a=null,R=e(j))}else a=null,R=e(j);return null!==a&&(a=function(a,b,c,d){return["comment",d.join("")].concat([["line",b],["col",c]])}(i.offset,i.line,i.column,a[1])),null===a&&(R=e(i)),S--,0===S&&null===a&&g("comment"),a}function I(){var a,b,d,h,i,j,k,l,m,n,o;if(m=e(R),a=J(),null!==a){for(b=[],d=O();null!==d;)b.push(d),d=O();if(null!==b)if(/^[#?^><+%:@\/~%]/.test(c.charAt(R.offset))?(d=c.charAt(R.offset),f(R,1)):(d=null,0===S&&g("[#?^><+%:@\\/~%]")),null!==d){for(h=[],i=O();null!==i;)h.push(i),i=O();if(null!==h){if(n=e(R),o=e(R),S++,j=K(),S--,null===j?j="":(j=null,R=e(o)),null!==j?(o=e(R),S++,k=N(),S--,null===k?k="":(k=null,R=e(o)),null!==k?(c.length>R.offset?(l=c.charAt(R.offset),f(R,1)):(l=null,0===S&&g("any character")),null!==l?j=[j,k,l]:(j=null,R=e(n))):(j=null,R=e(n))):(j=null,R=e(n)),null!==j)for(i=[];null!==j;)i.push(j),n=e(R),o=e(R),S++,j=K(),S--,null===j?j="":(j=null,R=e(o)),null!==j?(o=e(R),S++,k=N(),S--,null===k?k="":(k=null,R=e(o)),null!==k?(c.length>R.offset?(l=c.charAt(R.offset),f(R,1)):(l=null,0===S&&g("any character")),null!==l?j=[j,k,l]:(j=null,R=e(n))):(j=null,R=e(n))):(j=null,R=e(n));else i=null;if(null!==i){for(j=[],k=O();null!==k;)j.push(k),k=O();null!==j?(k=K(),null!==k?a=[a,b,d,h,i,j,k]:(a=null,R=e(m))):(a=null,R=e(m))}else a=null,R=e(m)}else a=null,R=e(m)}else a=null,R=e(m);else a=null,R=e(m)}else a=null,R=e(m);return null===a&&(a=p()),a}function J(){var a;return 123===c.charCodeAt(R.offset)?(a="{",f(R,1)):(a=null,0===S&&g('"{"')),a}function K(){var a;return 125===c.charCodeAt(R.offset)?(a="}",f(R,1)):(a=null,0===S&&g('"}"')),a}function L(){var a;return 91===c.charCodeAt(R.offset)?(a="[",f(R,1)):(a=null,0===S&&g('"["')),a}function M(){var a;return 93===c.charCodeAt(R.offset)?(a="]",f(R,1)):(a=null,0===S&&g('"]"')),a}function N(){var a;return 10===c.charCodeAt(R.offset)?(a="\n",f(R,1)):(a=null,0===S&&g('"\\n"')),null===a&&("\r\n"===c.substr(R.offset,2)?(a="\r\n",f(R,2)):(a=null,0===S&&g('"\\r\\n"')),null===a&&(13===c.charCodeAt(R.offset)?(a="\r",f(R,1)):(a=null,0===S&&g('"\\r"')),null===a&&(8232===c.charCodeAt(R.offset)?(a="\u2028",f(R,1)):(a=null,0===S&&g('"\\u2028"')),null===a&&(8233===c.charCodeAt(R.offset)?(a="\u2029",f(R,1)):(a=null,0===S&&g('"\\u2029"')))))),a -}function O(){var a;return/^[\t\x0B\f \xA0\uFEFF]/.test(c.charAt(R.offset))?(a=c.charAt(R.offset),f(R,1)):(a=null,0===S&&g("[\\t\\x0B\\f \\xA0\\uFEFF]")),null===a&&(a=N()),a}function P(a){a.sort();for(var b=null,c=[],d=0;d<a.length;d++)a[d]!==b&&(c.push(a[d]),b=a[d]);return c}var Q={body:h,part:i,section:j,sec_tag_start:k,end_tag:l,context:m,params:n,bodies:o,reference:p,partial:q,filters:r,special:s,identifier:t,number:u,"float":v,integer:w,path:x,key:y,array:z,array_part:A,inline:B,inline_part:C,buffer:D,literal:E,esc:F,raw:G,comment:H,tag:I,ld:J,rd:K,lb:L,rb:M,eol:N,ws:O};if(void 0!==d){if(void 0===Q[d])throw new Error("Invalid rule name: "+b(d)+".")}else d="body";var R={offset:0,line:1,column:1,seenCR:!1},S=0,T={offset:0,line:1,column:1,seenCR:!1},U=[],V=Q[d]();if(null===V||R.offset!==c.length){var W=Math.max(R.offset,T.offset),X=W<c.length?c.charAt(W):null,Y=R.offset>T.offset?R:T;throw new a.SyntaxError(P(U),X,W,Y.line,Y.column)}return V},toSource:function(){return this._source}};return c.SyntaxError=function(a,c,d,e,f){function g(a,c){var d,e;switch(a.length){case 0:d="end of input";break;case 1:d=a[0];break;default:d=a.slice(0,a.length-1).join(", ")+" or "+a[a.length-1]}return e=c?b(c):"end of input","Expected "+d+" but "+e+" found."}this.name="SyntaxError",this.expected=a,this.found=c,this.message=g(a,c),this.offset=d,this.line=e,this.column=f},c.SyntaxError.prototype=Error.prototype,c}();return dust.parse=a.parse,a}),function(a,b){"object"==typeof exports?module.exports=b(require("./parser").parse,require("./dust")):b(a.dust.parse,a.dust)}(this,function(a,dust){function b(a){var b={};return n.filterNode(b,a)}function c(a,b){var c,d,e,f=[b[0]];for(c=1,d=b.length;d>c;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 +!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,GT=/>/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.description<b.description?-1:a.description>b.description?1:0});b<a.length;)a[b-1]===a[b]?a.splice(b,1):b++}function h(a,b){function c(a){function b(a){return a.charCodeAt(0).toString(16).toUpperCase()}return a.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(a){return"\\x0"+b(a)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(a){return"\\x"+b(a)}).replace(/[\u0180-\u0FFF]/g,function(a){return"\\u0"+b(a)}).replace(/[\u1080-\uFFFF]/g,function(a){return"\\u"+b(a)})}var d,e,f,g=new Array(a.length);for(f=0;f<a.length;f++)g[f]=a[f].description;return d=a.length>1?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=e<a.length?a.charAt(e):null;return null!==d&&g(d),new b(null!==c?c:h(d,j),d,j,e,i.line,i.column)}function i(){var a;return a=j()}function j(){var a,b,c;for(a=md,b=[],c=k();c!==T;)b.push(c),c=k();return b!==T&&(nd=a,b=W(b)),a=b}function k(){var a;return a=I(),a===T&&(a=J(),a===T&&(a=l(),a===T&&(a=s(),a===T&&(a=u(),a===T&&(a=r(),a===T&&(a=F())))))),a}function l(){var b,c,d,e,f,h,i,k;if(sd++,b=md,c=m(),c!==T){for(d=[],e=Q();e!==T;)d.push(e),e=Q();d!==T?(e=M(),e!==T?(f=j(),f!==T?(h=q(),h!==T?(i=n(),i===T&&(i=Z),i!==T?(nd=md,k=$(c,f,h,i),k=k?_:Y,k!==T?(nd=b,c=ab(c,f,h,i),b=c):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)}else md=b,b=Y;if(b===T)if(b=md,c=m(),c!==T){for(d=[],e=Q();e!==T;)d.push(e),e=Q();d!==T?(47===a.charCodeAt(md)?(e=bb,md++):(e=T,0===sd&&g(cb)),e!==T?(f=M(),f!==T?(nd=b,c=db(c),b=c):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)}else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(X)),b}function m(){var b,c,d,e,f,h,i;if(b=md,c=L(),c!==T)if(eb.test(a.charAt(md))?(d=a.charAt(md),md++):(d=T,0===sd&&g(fb)),d!==T){for(e=[],f=Q();f!==T;)e.push(f),f=Q();e!==T?(f=v(),f!==T?(h=o(),h!==T?(i=p(),i!==T?(nd=b,c=gb(d,f,h,i),b=c):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)}else md=b,b=Y;else md=b,b=Y;return b}function n(){var b,c,d,e,f,h,i;if(sd++,b=md,c=L(),c!==T)if(47===a.charCodeAt(md)?(d=bb,md++):(d=T,0===sd&&g(cb)),d!==T){for(e=[],f=Q();f!==T;)e.push(f),f=Q();if(e!==T)if(f=v(),f!==T){for(h=[],i=Q();i!==T;)h.push(i),i=Q();h!==T?(i=M(),i!==T?(nd=b,c=ib(f),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;return sd--,b===T&&(c=T,0===sd&&g(hb)),b}function o(){var b,c,d,e;return b=md,c=md,58===a.charCodeAt(md)?(d=jb,md++):(d=T,0===sd&&g(kb)),d!==T?(e=v(),e!==T?(nd=c,d=lb(e),c=d):(md=c,c=Y)):(md=c,c=Y),c===T&&(c=Z),c!==T&&(nd=b,c=mb(c)),b=c}function p(){var b,c,d,e,f,h,i;if(sd++,b=md,c=[],d=md,e=[],f=Q(),f!==T)for(;f!==T;)e.push(f),f=Q();else e=Y;for(e!==T?(f=A(),f!==T?(61===a.charCodeAt(md)?(h=ob,md++):(h=T,0===sd&&g(pb)),h!==T?(i=w(),i===T&&(i=v(),i===T&&(i=D())),i!==T?(nd=d,e=qb(f,i),d=e):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y);d!==T;){if(c.push(d),d=md,e=[],f=Q(),f!==T)for(;f!==T;)e.push(f),f=Q();else e=Y;e!==T?(f=A(),f!==T?(61===a.charCodeAt(md)?(h=ob,md++):(h=T,0===sd&&g(pb)),h!==T?(i=w(),i===T&&(i=v(),i===T&&(i=D())),i!==T?(nd=d,e=qb(f,i),d=e):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)}return c!==T&&(nd=b,c=rb(c)),b=c,sd--,b===T&&(c=T,0===sd&&g(nb)),b}function q(){var b,c,d,e,f,h,i,k;for(sd++,b=md,c=[],d=md,e=L(),e!==T?(58===a.charCodeAt(md)?(f=jb,md++):(f=T,0===sd&&g(kb)),f!==T?(h=A(),h!==T?(i=M(),i!==T?(k=j(),k!==T?(nd=d,e=qb(h,k),d=e):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y);d!==T;)c.push(d),d=md,e=L(),e!==T?(58===a.charCodeAt(md)?(f=jb,md++):(f=T,0===sd&&g(kb)),f!==T?(h=A(),h!==T?(i=M(),i!==T?(k=j(),k!==T?(nd=d,e=qb(h,k),d=e):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y)):(md=d,d=Y);return c!==T&&(nd=b,c=tb(c)),b=c,sd--,b===T&&(c=T,0===sd&&g(sb)),b}function r(){var a,b,c,d,e;return sd++,a=md,b=L(),b!==T?(c=v(),c!==T?(d=t(),d!==T?(e=M(),e!==T?(nd=a,b=vb(c,d),a=b):(md=a,a=Y)):(md=a,a=Y)):(md=a,a=Y)):(md=a,a=Y),sd--,a===T&&(b=T,0===sd&&g(ub)),a}function s(){var b,c,d,e,f,h,i,j,k,l;if(sd++,b=md,c=L(),c!==T)if(62===a.charCodeAt(md)?(d=xb,md++):(d=T,0===sd&&g(yb)),d===T&&(43===a.charCodeAt(md)?(d=zb,md++):(d=T,0===sd&&g(Ab))),d!==T){for(e=[],f=Q();f!==T;)e.push(f),f=Q();if(e!==T)if(f=md,h=A(),h!==T&&(nd=f,h=Bb(h)),f=h,f===T&&(f=D()),f!==T)if(h=o(),h!==T)if(i=p(),i!==T){for(j=[],k=Q();k!==T;)j.push(k),k=Q();j!==T?(47===a.charCodeAt(md)?(k=bb,md++):(k=T,0===sd&&g(cb)),k!==T?(l=M(),l!==T?(nd=b,c=Cb(d,f,h,i),b=c):(md=b,b=Y)):(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;else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(wb)),b}function t(){var b,c,d,e,f;for(sd++,b=md,c=[],d=md,124===a.charCodeAt(md)?(e=Eb,md++):(e=T,0===sd&&g(Fb)),e!==T?(f=A(),f!==T?(nd=d,e=lb(f),d=e):(md=d,d=Y)):(md=d,d=Y);d!==T;)c.push(d),d=md,124===a.charCodeAt(md)?(e=Eb,md++):(e=T,0===sd&&g(Fb)),e!==T?(f=A(),f!==T?(nd=d,e=lb(f),d=e):(md=d,d=Y)):(md=d,d=Y);return c!==T&&(nd=b,c=Gb(c)),b=c,sd--,b===T&&(c=T,0===sd&&g(Db)),b}function u(){var b,c,d,e,f;return sd++,b=md,c=L(),c!==T?(126===a.charCodeAt(md)?(d=Ib,md++):(d=T,0===sd&&g(Jb)),d!==T?(e=A(),e!==T?(f=M(),f!==T?(nd=b,c=Kb(e),b=c):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y),sd--,b===T&&(c=T,0===sd&&g(Hb)),b}function v(){var a,b;return sd++,a=md,b=z(),b!==T&&(nd=a,b=Mb(b)),a=b,a===T&&(a=md,b=A(),b!==T&&(nd=a,b=Nb(b)),a=b),sd--,a===T&&(b=T,0===sd&&g(Lb)),a}function w(){var a,b;return sd++,a=md,b=x(),b===T&&(b=y()),b!==T&&(nd=a,b=Pb(b)),a=b,sd--,a===T&&(b=T,0===sd&&g(Ob)),a}function x(){var b,c,d,e,f;if(sd++,b=md,c=y(),c!==T)if(46===a.charCodeAt(md)?(d=Rb,md++):(d=T,0===sd&&g(Sb)),d!==T){if(e=[],f=y(),f!==T)for(;f!==T;)e.push(f),f=y();else e=Y;e!==T?(nd=b,c=Tb(c,e),b=c):(md=b,b=Y)}else md=b,b=Y;else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(Qb)),b}function y(){var b,c,d;if(sd++,b=md,c=[],Vb.test(a.charAt(md))?(d=a.charAt(md),md++):(d=T,0===sd&&g(Wb)),d!==T)for(;d!==T;)c.push(d),Vb.test(a.charAt(md))?(d=a.charAt(md),md++):(d=T,0===sd&&g(Wb));else c=Y;return c!==T&&(nd=b,c=Xb(c)),b=c,sd--,b===T&&(c=T,0===sd&&g(Ub)),b}function z(){var b,c,d,e;if(sd++,b=md,c=A(),c===T&&(c=Z),c!==T){if(d=[],e=C(),e===T&&(e=B()),e!==T)for(;e!==T;)d.push(e),e=C(),e===T&&(e=B());else d=Y;d!==T?(nd=b,c=Zb(c,d),b=c):(md=b,b=Y)}else md=b,b=Y;if(b===T)if(b=md,46===a.charCodeAt(md)?(c=Rb,md++):(c=T,0===sd&&g(Sb)),c!==T){for(d=[],e=C(),e===T&&(e=B());e!==T;)d.push(e),e=C(),e===T&&(e=B());d!==T?(nd=b,c=$b(d),b=c):(md=b,b=Y)}else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(Yb)),b}function A(){var b,c,d,e;if(sd++,b=md,ac.test(a.charAt(md))?(c=a.charAt(md),md++):(c=T,0===sd&&g(bc)),c!==T){for(d=[],cc.test(a.charAt(md))?(e=a.charAt(md),md++):(e=T,0===sd&&g(dc));e!==T;)d.push(e),cc.test(a.charAt(md))?(e=a.charAt(md),md++):(e=T,0===sd&&g(dc));d!==T?(nd=b,c=ec(c,d),b=c):(md=b,b=Y)}else md=b,b=Y;return sd--,b===T&&(c=T,0===sd&&g(_b)),b}function B(){var b,c,d,e,f,h;if(sd++,b=md,c=md,d=N(),d!==T){if(e=md,f=[],Vb.test(a.charAt(md))?(h=a.charAt(md),md++):(h=T,0===sd&&g(Wb)),h!==T)for(;h!==T;)f.push(h),Vb.test(a.charAt(md))?(h=a.charAt(md),md++):(h=T,0===sd&&g(Wb));else f=Y;f!==T&&(nd=e,f=gc(f)),e=f,e===T&&(e=v()),e!==T?(f=O(),f!==T?(nd=c,d=hc(e),c=d):(md=c,c=Y)):(md=c,c=Y)}else md=c,c=Y;return c!==T?(d=C(),d===T&&(d=Z),d!==T?(nd=b,c=ic(c,d),b=c):(md=b,b=Y)):(md=b,b=Y),sd--,b===T&&(c=T,0===sd&&g(fc)),b}function C(){var b,c,d,e,f;if(sd++,b=md,c=[],d=md,46===a.charCodeAt(md)?(e=Rb,md++):(e=T,0===sd&&g(Sb)),e!==T?(f=A(),f!==T?(nd=d,e=kc(f),d=e):(md=d,d=Y)):(md=d,d=Y),d!==T)for(;d!==T;)c.push(d),d=md,46===a.charCodeAt(md)?(e=Rb,md++):(e=T,0===sd&&g(Sb)),e!==T?(f=A(),f!==T?(nd=d,e=kc(f),d=e):(md=d,d=Y)):(md=d,d=Y);else c=Y;return c!==T?(d=B(),d===T&&(d=Z),d!==T?(nd=b,c=lc(c,d),b=c):(md=b,b=Y)):(md=b,b=Y),sd--,b===T&&(c=T,0===sd&&g(jc)),b}function D(){var b,c,d,e;if(sd++,b=md,34===a.charCodeAt(md)?(c=nc,md++):(c=T,0===sd&&g(oc)),c!==T?(34===a.charCodeAt(md)?(d=nc,md++):(d=T,0===sd&&g(oc)),d!==T?(nd=b,c=pc(),b=c):(md=b,b=Y)):(md=b,b=Y),b===T&&(b=md,34===a.charCodeAt(md)?(c=nc,md++):(c=T,0===sd&&g(oc)),c!==T?(d=G(),d!==T?(34===a.charCodeAt(md)?(e=nc,md++):(e=T,0===sd&&g(oc)),e!==T?(nd=b,c=qc(d),b=c):(md=b,b=Y)):(md=b,b=Y)):(md=b,b=Y),b===T))if(b=md,34===a.charCodeAt(md)?(c=nc,md++):(c=T,0===sd&&g(oc)),c!==T){if(d=[],e=E(),e!==T)for(;e!==T;)d.push(e),e=E();else d=Y;d!==T?(34===a.charCodeAt(md)?(e=nc,md++):(e=T,0===sd&&g(oc)),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 E(){var a,b;return a=u(),a===T&&(a=r(),a===T&&(a=md,b=G(),b!==T&&(nd=a,b=sc(b)),a=b)),a}function F(){var b,c,d,e,f,h,i,j;if(sd++,b=md,c=P(),c!==T){for(d=[],e=Q();e!==T;)d.push(e),e=Q();d!==T?(nd=b,c=uc(c,d),b=c):(md=b,b=Y)}else md=b,b=Y;if(b===T){if(b=md,c=[],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),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&&md<a.length&&g({type:"end",description:"end of input"}),h(null,rd,qd)}return a(b,Error),{SyntaxError:b,parse:c}}();return dust.parse=a.parse,a}),function(a,b){"object"==typeof exports?module.exports=b(require("./parser").parse,require("./dust")):b(a.dust.parse,a.dust)}(this,function(a,dust){function b(a){var b={};return n.filterNode(b,a)}function c(a,b){var c,d,e,f=[b[0]];for(c=1,d=b.length;d>c;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/package.json b/package.json index 0b434dd2..e4141f22 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dustjs-linkedin", "title": "Dust - Asynchronous Templating", - "version": "2.4.1", + "version": "2.4.2", "author": { "name": "Aleksander Williams", "url": "http://akdubya.github.com/dustjs"