dustjs-linkedin
Advanced tools
Comparing version 2.6.1 to 2.6.2
{ | ||
"name": "dustjs-linkedin", | ||
"version": "2.6.1", | ||
"version": "2.6.2", | ||
"homepage": "https://github.com/linkedin/dustjs", | ||
@@ -41,2 +41,3 @@ "authors": [ | ||
"docs", | ||
"examples", | ||
"lib", | ||
@@ -47,2 +48,3 @@ "node_modules", | ||
"tmp", | ||
"index.js", | ||
"Gruntfile.js", | ||
@@ -49,0 +51,0 @@ "package.json" |
297
CHANGELOG.md
## Change Log | ||
### v2.6.0 (2015/03/05 18:00 +00:00) | ||
- [#545](https://github.com/linkedin/dustjs/pull/545) New dust command-line compiler (@sethkinast) | ||
- [#536](https://github.com/linkedin/dustjs/pull/536) Add AMD (require.js) compatibility (@sethkinast) | ||
- [#543](https://github.com/linkedin/dustjs/pull/543) Replaced util.print/util.puts with console.log (@hunterchristian) | ||
- [#541](https://github.com/linkedin/dustjs/pull/541) Escape template names (@aredridel) | ||
- [#540](https://github.com/linkedin/dustjs/pull/540) Escape values when using json filter (@jimmyhchan) | ||
- [#531](https://github.com/linkedin/dustjs/pull/531) Fix whitespace in partials not being preserved (@BradEstey) | ||
- [#534](https://github.com/linkedin/dustjs/pull/534) Stringify things before calling escapeHtml on them (@sethkinast) | ||
- [#533](https://github.com/linkedin/dustjs/pull/533) Add dust.version (@sethkinast) | ||
- [#529](https://github.com/linkedin/dustjs/pull/529) Fix IE7 by removing trailing comma (@jrrbru) | ||
### v2.6.2 (2015/03/26 20:27 +00:00) | ||
- [#593](https://github.com/linkedin/dustjs/pull/593) npm upgrade (@sethkinast) | ||
- [#590](https://github.com/linkedin/dustjs/pull/590) Add deep resolution of Thenables in context (@sethkinast) | ||
- [#583](https://github.com/linkedin/dustjs/pull/583) Move lib/server to index (@sethkinast) | ||
- [#587](https://github.com/linkedin/dustjs/pull/587) Allow Rhino test failures to break the build (and fix a test typo that broke Rhino) (@sethkinast) | ||
- [#582](https://github.com/linkedin/dustjs/pull/582) Refactor main Dust module's global context (@sethkinast) | ||
- [#579](https://github.com/linkedin/dustjs/pull/579) Clean up / refactor logging (@sethkinast) | ||
- [#569](https://github.com/linkedin/dustjs/pull/569) Thenable support (@sethkinast) | ||
- [#578](https://github.com/linkedin/dustjs/pull/578) Add --watch support to dustc (@sethkinast) | ||
- [#577](https://github.com/linkedin/dustjs/pull/577) Adding examples! (@sethkinast) | ||
- [#559](https://github.com/linkedin/dustjs/pull/559) Add `context.clone` and `context.pop` and simplify chunk.partial. (@sethkinast) | ||
- [#555](https://github.com/linkedin/dustjs/pull/555) Add Context#resolve (@sethkinast) | ||
### v2.6.1 (2015/03/11 23:38 +00:00) | ||
- [#557](https://github.com/linkedin/dustjs/pull/557) Fix the output of format (whitespace-only) blocks inside inline partials (@sethkinast) | ||
- [#546](https://github.com/linkedin/dustjs/pull/546) Add Travis test targets for node 0.12 and iojs (@sethkinast) | ||
- [#552](https://github.com/linkedin/dustjs/pull/552) Update bower file (@sethkinast) | ||
- [#550](https://github.com/linkedin/dustjs/pull/550) Core grammar: support negative numbers passed as params (@jasonbelmonti) | ||
### v2.6.0 (2015/03/05 01:30 +00:00) | ||
- [#545](https://github.com/linkedin/dustjs/pull/545) New dustc compiler. This breaks backward compat, but allows streaming output and a usage manual. Also includes tests that were nonexistent previously. (@sethkinast) | ||
- [#536](https://github.com/linkedin/dustjs/pull/536) Add AMD (require.js) compatibility. This includes the core, compiler, parser, and support for compiling templates as AMD modules. Have to set define.amd.dust to true to allow dust to be loaded as an AMD module, and dust.config.amd to true to compile templates as AMD modules. (@sethkinast) | ||
- [#543](https://github.com/linkedin/dustjs/pull/543) dustc: replace util.print/util.puts with console.log (@hunterchristian) | ||
- [#541](https://github.com/linkedin/dustjs/pull/541) Escape template names in case they contain non-JS-safe characters (@aredridel) | ||
- [#540](https://github.com/linkedin/dustjs/pull/540) escape values (\u2028, \u2029 and <) when using json filter (@jimmyhchan) | ||
- [#534](https://github.com/linkedin/dustjs/pull/534) Stringify things before calling escapeHtml on them in case their stringified representation contains HTML (@sethkinast) | ||
- [#537](https://github.com/linkedin/dustjs/pull/537) Stop archiving old releases (@sethkinast) | ||
- [#533](https://github.com/linkedin/dustjs/pull/533) Add dust.version and bump it during grunt-bump (@sethkinast) | ||
- [#529](https://github.com/linkedin/dustjs/pull/529) Fix hanging comma in dust.config. Fixes IE7. (@jrrbru) | ||
- [#526](https://github.com/linkedin/dustjs/pull/526) Don't stringify dust.log messages (@sethkinast) | ||
### v2.5.1 (2014/11/20 00:58 +00:00) | ||
### v2.5.1 (2014/11/20 01:08 +00:00) | ||
- [#522](https://github.com/linkedin/dustjs/pull/522) Fix the use of a multi-level object key (e.g. foo.bar) as the key for an index lookup inside non-self-closing tags. (@sethkinast) | ||
- [#520](https://github.com/linkedin/dustjs/pull/520) Update changelog to 2.5.0 (@sethkinast) | ||
@@ -27,3 +47,5 @@ ### v2.5.0 (2014/11/04 00:15 +00:00) | ||
### v2.4.2 (2014/09/09 23:11 +00:00) | ||
- [#497](https://github.com/linkedin/dustjs/pull/497) Upgrade to pegJS 0.8 - This change corresponds to a 90% reduction in template compile time. (@sethkinast) | ||
- [#497](https://github.com/linkedin/dustjs/pull/497) Upgrade to pegJS 0.8 - This change corresponds to a 90% reduction in template compile time. (@sethkinast) | ||
### v2.3.6 (2014/09/09 22:33 +00:00) | ||
- [#495](https://github.com/linkedin/dustjs/pull/495) Catch syntax errors in context and fail gracefully (@sethkinast) | ||
@@ -36,24 +58,35 @@ | ||
### v2.4.0 (2014/06/11 01:32 +00:00) | ||
- [#472](https://github.com/linkedin/dustjs/pull/472) #469 Prevent references from looking in the prototype. Previously, {arr.sort} was possible even if sort was not a function in the arr object, since it was looking in the Array prototype. (@jimmyhchan) | ||
- [#441](https://github.com/linkedin/dustjs/pull/441) Make default params type to an object instead of null (@prashn64) | ||
- [#447](https://github.com/linkedin/dustjs/pull/447) deprecate the internal property context.isFunction. this is no longer needed. (@prashn64) | ||
- [#424](https://github.com/linkedin/dustjs/pull/424) Set up dev flow with grunt and fix coverage report (@kate2753) | ||
- [#471](https://github.com/linkedin/dustjs/pull/471) Errors thrown from render will now call populate the error in the callback. Previously, thrown errors will immediately fail and not call the callback. Issue #381, Address #468: Errors thrown from stream now will invoke the `error` listener with the error object. Previously, these errors could not be caught and the process will hang. Deprecated/remove: `dust.onError`, `dust.silenceErrors`. To see runtime errors, look at the error in the callback. breaking change: `dust.log` with an error no longer throws that error (@prashn64) | ||
- [#475](https://github.com/linkedin/dustjs/pull/475) remove config set on before install for travis build (@prashn64) | ||
- [#474](https://github.com/linkedin/dustjs/pull/474) travis build fix for minimatch grunt module (@prashn64) | ||
- [#470](https://github.com/linkedin/dustjs/pull/470) Ensure client bundlers load only client-side code (@patrick-steele-idem) | ||
- [#474](https://github.com/linkedin/dustjs/pull/474) travis build fix for minimatch grunt module (@prashn64) | ||
- [#475](https://github.com/linkedin/dustjs/pull/475) remove config set on before install for travis build (@prashn64) | ||
- [#471](https://github.com/linkedin/dustjs/pull/471) Errors thrown from render will now call populate the error in the callback. Previously, thrown errors will immediately fail and not call the callback. Issue #381, | ||
Address #468: Errors thrown from stream now will invoke the `error` listener with the error object. Previously, these errors could not be caught and the process will hang. | ||
### v2.3.5 (2014/05/08 21:31 +00:00) | ||
- [#463](https://github.com/linkedin/dustjs/pull/463) Rendering performance improvements by simplifying logging (@kate2753) | ||
Deprecated/remove: `dust.onError`, `dust.silenceErrors`. To see runtime errors, look at the error in the callback. | ||
breaking change: `dust.log` with an error no longer throws that error (@prashn64) | ||
- [#424](https://github.com/linkedin/dustjs/pull/424) Set up dev flow with grunt and fix coverage report (@kate2753) | ||
- [#447](https://github.com/linkedin/dustjs/pull/447) deprecate the internal property context.isFunction. this is no longer needed. (@prashn64) | ||
- [#441](https://github.com/linkedin/dustjs/pull/441) Make default params type to an object instead of github.com (@prashn64) | ||
- [#472](https://github.com/linkedin/dustjs/pull/472) #469 Prevent references from looking in the prototype. | ||
### v2.2.10 (2014/05/07 23:39 +00:00) | ||
- [#444](https://github.com/linkedin/dustjs/pull/444) make console.log available for logging statements in node environment by passing the proper global (@bgmort) | ||
Previously, {arr.sort} was possible even if sort was not a function in the arr object, since it was looking in the Array prototype. (@jimmyhchan) | ||
### v2.3.4 (2014/03/06 22:34 +00:00) | ||
- [#435](https://github.com/linkedin/dustjs/pull/435) indexInArray fix. (@kate2753) | ||
### v2.3.5 (2014/05/08 21:31 +00:00) | ||
- [#463](https://github.com/linkedin/dustjs/pull/463) Rendering performance improvements by simplifying logging (@prashn64) | ||
### v2.1.4 (2014/03/06 00:32 +00:00) | ||
- [#432](https://github.com/linkedin/dustjs/pull/432) add temporary fix for ssl problems with npm until travis itself updates ... (@prashn64) | ||
- [#430](https://github.com/linkedin/dustjs/pull/430) Only have the logger.log call once inside logger.log (@prashn64) | ||
- [#429](https://github.com/linkedin/dustjs/pull/429) Patch 2.1.X 2.2.X 2.3.X to fix IE9 and below issues when dust debugging is on. Added a cross-browser/node/rhino version of indexOf and logger.log. (@kate2753) | ||
### v2.3.4 (2014/03/06 22:34 +00:00) | ||
- [#435](https://github.com/linkedin/dustjs/pull/435) indexInArray fix. (@prashn64) | ||
### v2.1.3 (2014/02/27 08:18 +00:00) | ||
- [#426](https://github.com/linkedin/dustjs/pull/426) Add changelog (@lalitkapoor) | ||
- [#427](https://github.com/linkedin/dustjs/pull/427) Add 2.2.7 which is identical to 2.2.6 for npm (@prashn64) | ||
### v2.2.7 (2014/02/24 23:06 +00:00) | ||
- [#419](https://github.com/linkedin/dustjs/pull/419) Fix Context.prototype._get to work with context switching when calling partials and make the 2.2.x+ compiler fully backwards compatible. (@kate2753) | ||
### v2.2.6 (2014/02/13 00:18 +00:00) | ||
- [#420](https://github.com/linkedin/dustjs/pull/420) Make the compiler backwards compatible with runtime versions prior to 2.2.x (@kate2753) | ||
### v2.3.3 (2014/01/31 21:29 +00:00) | ||
@@ -69,26 +102,22 @@ - [#416](https://github.com/linkedin/dustjs/pull/416) Lower most errors to warnings. (@prashn64) | ||
### v2.3.0 (2014/01/17 00:26 +00:00) | ||
- [#405](https://github.com/linkedin/dustjs/pull/405) Fix Grunt release and don't push upstream by default (safer) (@jimmyhchan) | ||
- [#392](https://github.com/linkedin/dustjs/pull/392) Add Rhino and Rhino unit tests (@kate2753) | ||
- [#404](https://github.com/linkedin/dustjs/pull/404) revert package.json back to 2.2.3 (@prashn64) | ||
- [#403](https://github.com/linkedin/dustjs/pull/403) bump commit does not support tasks (@jimmyhchan) | ||
- [#395](https://github.com/linkedin/dustjs/pull/395) fail hard when a name is not explicitly defined in dust.compile (@prashn64) | ||
- [#399](https://github.com/linkedin/dustjs/pull/399) Don't swallow all errors by default (Issue #381). Deprecate dust.isDebug and dust.onError. Instead, just use debugLevel and dust.log(message, 'ERROR'), respectively. Add a dust.silenceErrors flag to swallow all errors. (@prashn64) | ||
- [#395](https://github.com/linkedin/dustjs/pull/395) fail hard when a name is not explicitly defined in dust.compile (@prashn64) | ||
- [#403](https://github.com/linkedin/dustjs/pull/403) bump commit does not support tasks (@jimmyhchan) | ||
- [#404](https://github.com/linkedin/dustjs/pull/404) revert package.json back to 2.2.3 (@prashn64) | ||
- [#392](https://github.com/linkedin/dustjs/pull/392) Add Rhino and Rhino unit tests (@kate2753) | ||
- [#405](https://github.com/linkedin/dustjs/pull/405) Fix Grunt release and don't push upstream by default (safer) (@jimmyhchan) | ||
### v2.2.10 (2014/05/07 23:39 +00:00) | ||
- [#444](https://github.com/linkedin/dustjs/pull/444) make console.log available for logging statements in node environment by passing the proper global (@bgmort) | ||
### v2.1.1 (2014/01/16 01:09 +00:00) | ||
- [#382](https://github.com/linkedin/dustjs/pull/382) remove the globals and isolate parser and compiler (@jimmyhchan) | ||
- [#334](https://github.com/linkedin/dustjs/pull/334) Issue #332 provide a raw input syntax similar to comments {!...!} where newlines, spaces and braces are kept. (@jimmyhchan) | ||
- [#371](https://github.com/linkedin/dustjs/pull/371) Fix our release process + add bower.json + jshint + cleanup master (@jimmyhchan) | ||
### v2.2.7 (2014/02/24 23:06 +00:00) | ||
- [#419](https://github.com/linkedin/dustjs/pull/419) Fix Context.prototype._get to work with context switching when calling partials and make the 2.2.x+ compiler fully backwards compatible. (@kate2753) | ||
### v2.2.6 (2014/02/13 00:18 +00:00) | ||
- [#420](https://github.com/linkedin/dustjs/pull/420) Make the compiler backwards compatible with runtime versions prior to 2.2.x (@kate2753) | ||
### v2.2.3 (2013/12/06 02:02 +00:00) | ||
- [#374](https://github.com/linkedin/dustjs/pull/374) Properly generate .min files for 2.2.3 (@kate2753) | ||
- [#372](https://github.com/linkedin/dustjs/pull/372) Regenerate dist files for v2.2.3 to include $idx fixes (@kate2753) | ||
- [#374](https://github.com/linkedin/dustjs/pull/374) Properly generate .min files for 2.2.3 (@kate2753) | ||
### v2.2.2 (2013/11/28 00:10 +00:00) | ||
- [#368](https://github.com/linkedin/dustjs/pull/368) Add context.getTemplateName. This method now correctly returns the template name even for directly loaded templates being used as partials. For end users please use this api for getting the template name instead of ctx.templatename (@prashn64) | ||
- [#363](https://github.com/linkedin/dustjs/pull/363) Issue #340. Remove old optimization to avoid looking at arrays in get. (@rragan) | ||
- [#362](https://github.com/linkedin/dustjs/pull/362) remove node_modules directory (@wizardzloy) | ||
- [#363](https://github.com/linkedin/dustjs/pull/363) Issue #340. Remove old optimization to avoid looking at arrays in get. (@rragan) | ||
- [#368](https://github.com/linkedin/dustjs/pull/368) Add context.getTemplateName. This method now correctly returns the template name even for directly loaded templates being used as partials. For end users please use this api for getting the template name instead of ctx.templatename (@prashn64) | ||
@@ -98,45 +127,31 @@ ### v2.2.0 (2013/11/08 18:42 +00:00) | ||
### v2.1.4 (2014/03/06 00:32 +00:00) | ||
- [#429](https://github.com/linkedin/dustjs/pull/429) Patch 2.1.X 2.2.X 2.3.X to fix IE9 and below issues when dust debugging is on. Added a cross-browser/node/rhino version of indexOf and logger.log. (@prashn64) | ||
- [#430](https://github.com/linkedin/dustjs/pull/430) Only have the logger.log call once inside logger.log (@prashn64) | ||
- [#432](https://github.com/linkedin/dustjs/pull/432) add temporary fix for ssl problems with npm until travis itself updates ... (@prashn64) | ||
### v2.1.3 (2014/02/27 08:18 +00:00) | ||
- [#427](https://github.com/linkedin/dustjs/pull/427) Add 2.2.7 which is identical to 2.2.6 for npm (@prashn64) | ||
- [#426](https://github.com/linkedin/dustjs/pull/426) Add changelog (@lalitkapoor) | ||
### v2.1.1 (2014/01/16 01:09 +00:00) | ||
- [#371](https://github.com/linkedin/dustjs/pull/371) Fix our release process + add bower.json + jshint + cleanup master (@jimmyhchan) | ||
- [#334](https://github.com/linkedin/dustjs/pull/334) Issue #332 provide a raw input syntax similar to comments {!...!} where newlines, spaces and braces are kept. (@jimmyhchan) | ||
- [#382](https://github.com/linkedin/dustjs/pull/382) remove the globals and isolate parser and compiler (@jimmyhchan) | ||
### v2.1.0 (2013/10/25 08:44 +00:00) | ||
- [#350](https://github.com/linkedin/dustjs/pull/350) Support dynamic template names for the context's template name. (@johnsonlei) | ||
- [#355](https://github.com/linkedin/dustjs/pull/355) add a unit test for inline params with dashes (@prashn64) | ||
- [#347](https://github.com/linkedin/dustjs/pull/347) Dust error logging (@prashn64) | ||
- [#344](https://github.com/linkedin/dustjs/pull/344) Per discussions, this may be a bit premature. Revert "Merge pull request #279 from prashn64/master" until the api for debugging is more settled. (@prashn64) | ||
- [#279](https://github.com/linkedin/dustjs/pull/279) Client Side Debugging (@prashn64) | ||
- [#344](https://github.com/linkedin/dustjs/pull/344) Per discussions, this may be a bit premature. Revert "Merge pull request #279 from prashn64/master" until the api for debugging is more settled. (@prashn64) | ||
- [#347](https://github.com/linkedin/dustjs/pull/347) Dust error logging (@prashn64) | ||
- [#355](https://github.com/linkedin/dustjs/pull/355) add a unit test for inline params with dashes (@prashn64) | ||
- [#350](https://github.com/linkedin/dustjs/pull/350) Support dynamic template names for the context's template name. (@johnsonlei) | ||
### v2.0.3 (2013/09/06 23:23 +00:00) | ||
- [#338](https://github.com/linkedin/dustjs/pull/338) update to correct 2.0.3 (@prashn64) | ||
- [#335](https://github.com/linkedin/dustjs/pull/335) make context.templateName change into version 2.0.3 (@prashn64) | ||
- [#328](https://github.com/linkedin/dustjs/pull/328) Put templateName on the context instance instead of the context's globals. (@prashn64) | ||
- [#323](https://github.com/linkedin/dustjs/pull/323) Fix Issue #322. block name in template includes previous text by mistake (@rragan) | ||
- [#328](https://github.com/linkedin/dustjs/pull/328) Put templateName on the context instance instead of the context's globals. (@prashn64) | ||
- [#335](https://github.com/linkedin/dustjs/pull/335) make context.templateName change into version 2.0.3 (@prashn64) | ||
- [#338](https://github.com/linkedin/dustjs/pull/338) update to correct 2.0.3 (@prashn64) | ||
### v2.0.2 (2013/08/01 20:57 +00:00) | ||
- [#320](https://github.com/linkedin/dustjs/pull/320) Update parser.js to sync with latest dust.pegjs (@smfoote) | ||
- [#319](https://github.com/linkedin/dustjs/pull/319) Clarify comments on path search (@rragan) | ||
- [#318](https://github.com/linkedin/dustjs/pull/318) Fix issue #317. Falsey value at end of path (@rragan) | ||
- [#319](https://github.com/linkedin/dustjs/pull/319) Clarify comments on path search (@rragan) | ||
- [#320](https://github.com/linkedin/dustjs/pull/320) Update parser.js to sync with latest dust.pegjs (@smfoote) | ||
### v2.0.1 (2013/07/24 17:34 +00:00) | ||
- [#309](https://github.com/linkedin/dustjs/pull/309) Add lines and columns to dust.pegjs (@smfoote) | ||
- [#312](https://github.com/linkedin/dustjs/pull/312) Remove node_modules/jasmine_node (@smfoote) | ||
- [#309](https://github.com/linkedin/dustjs/pull/309) Add lines and columns to dust.pegjs (@smfoote) | ||
### v2.0.0 (2013/07/17 02:18 +00:00) | ||
- [#306](https://github.com/linkedin/dustjs/pull/306) add support for GH-292, support the template name in nested partials (@vybs) | ||
- [#305](https://github.com/linkedin/dustjs/pull/305) Remove option to control pathScope and remove tests for old getPath (@rragan) | ||
- [#304](https://github.com/linkedin/dustjs/pull/304) GH-292 support template name in nested partials, need a stack to store the current name (@vybs) | ||
- [#289](https://github.com/linkedin/dustjs/pull/289) Cache VM context across `dust.loadSource` calls. (@totherik) | ||
- [#271](https://github.com/linkedin/dustjs/pull/271) adding support for . path resolution in context get (@carchrae, @rragan) | ||
- [#2](https://github.com/linkedin/dustjs/pull/2) Fixed jasmine testRunner to understand base and options properties (@rragan) | ||
- [#271](https://github.com/linkedin/dustjs/pull/271) adding support for . path resolution in context get (@carchrae, @rragan) | ||
- [#289](https://github.com/linkedin/dustjs/pull/289) Cache VM context across `dust.loadSource` calls. (@totherik) | ||
- [#304](https://github.com/linkedin/dustjs/pull/304) GH-292 support template name in nested partials, need a stack to store the current name (@vybs) | ||
- [#305](https://github.com/linkedin/dustjs/pull/305) Remove option to control pathScope and remove tests for old getPath (@rragan) | ||
- [#306](https://github.com/linkedin/dustjs/pull/306) add support for GH-292, support the template name in nested partials (@vybs) | ||
@@ -147,64 +162,78 @@ ### v1.2.6 (2013/06/06 15:54 +00:00) | ||
### v1.2.5 (2013/06/02 21:25 +00:00) | ||
- [#25](https://github.com/linkedin/dustjs/pull/25) process.binding('evals') is now require('vm') (@stonecobra) | ||
- [#274](https://github.com/linkedin/dustjs/pull/274) GH-266 store rendered template in global (@vybs) | ||
- [#263](https://github.com/linkedin/dustjs/pull/263) Add forward slash and unit tests for j filter (@prashn64) | ||
### v1.2.3 (2013/04/11 17:47 +00:00) | ||
- [#253](https://github.com/linkedin/dustjs/pull/253) 2-3000% performance enhancement in IE7 (@jlkonsultab) | ||
- [#249](https://github.com/linkedin/dustjs/pull/249) Remove debugger in dust-full-1.2.1.js (@sethkinast) | ||
### v1.2.2 (2013/03/19 20:07 +00:00) | ||
- [#245](https://github.com/linkedin/dustjs/pull/245) Gh-208 - solve the incorrect error line reported in peg (@jairodemorais) | ||
- [#243](https://github.com/linkedin/dustjs/pull/243) compiler variable name changed to dustCompiler (@jairodemorais) | ||
- [#241](https://github.com/linkedin/dustjs/pull/241) using dust.isArray in place of Array.isArray (@jairodemorais) | ||
### v1.2.1 (2013/02/19 17:55 +00:00) | ||
- [#236](https://github.com/linkedin/dustjs/pull/236) eol added to buffer again. (@jairodemorais) | ||
### v1.2.0 (2013/02/08 17:56 +00:00) | ||
- [#223](https://github.com/linkedin/dustjs/pull/223) Fix for Issue #222. Code change + new test added to verify proper behavior (@rragan) | ||
- [#216](https://github.com/linkedin/dustjs/pull/216) add semicolons to dust compiler GH=215 (@jairodemorais) | ||
- [#188](https://github.com/linkedin/dustjs/pull/188) The whitespace grammar rule for partial was a little inconsistent with other tags. issue GH=187 fixed. (@jairodemorais) | ||
- [#166](https://github.com/linkedin/dustjs/pull/166) Add template strip of white space to dust.compile (optional defaults to not strip) (@smfoote) | ||
- [#183](https://github.com/linkedin/dustjs/pull/183) cover, uglify and jasmine move to dev dependencies. GH-183 (@jairodemorais) | ||
- [#168](https://github.com/linkedin/dustjs/pull/168) Minor README update (@sethmcl) | ||
- [#165](https://github.com/linkedin/dustjs/pull/165) improve description in unit tests (@vybs) | ||
- [#159](https://github.com/linkedin/dustjs/pull/159) fix the description on the core tests for $idx and $len for scalar (@vybs) | ||
- [#158](https://github.com/linkedin/dustjs/pull/158) fix the bad merge (@vybs) | ||
### v1.1.1 (2012/09/30 22:43 +00:00) | ||
- [#157](https://github.com/linkedin/dustjs/pull/157) Add unit tests for the pull/154 (@vybs) | ||
- [#154](https://github.com/linkedin/dustjs/pull/154) partials with parameters context was missing blocks (@jimmyhchan) | ||
- [#156](https://github.com/linkedin/dustjs/pull/156) Cleanup the helpers from the dust repo, fix the make test (@vybs) | ||
### v1.1.0 (2012/09/20 22:06 +00:00) | ||
- [#152](https://github.com/linkedin/dustjs/pull/152) Really undo 2760048: removing scalar block support (@jimmyhchan) | ||
- [#151](https://github.com/linkedin/dustjs/pull/151) add v1.1 files to the dist (@vybs) | ||
- [#146](https://github.com/linkedin/dustjs/pull/146) Remove the old grammartests file, since it renamed to coreTests now and guard against missing context head in section (@vybs) | ||
- [#145](https://github.com/linkedin/dustjs/pull/145) rename grammar tests to core tests, since it testing dust.js core functionality, also has GH-133, fix the missing helper case (@vybs) | ||
- [#144](https://github.com/linkedin/dustjs/pull/144) minor: reorganized the section code and documented some more as to how t... (@vybs) | ||
- [#143](https://github.com/linkedin/dustjs/pull/143) reverse the GH-134 since it is backward incompatible (@vybs) | ||
- [#142](https://github.com/linkedin/dustjs/pull/142) add another intersting test case with . and blocks (@vybs) | ||
- [#141](https://github.com/linkedin/dustjs/pull/141) Fixes for GH-134 (@vybs) | ||
- [#140](https://github.com/linkedin/dustjs/pull/140) GH-134 , remove support for scalar in the block # (@vybs) | ||
- [#139](https://github.com/linkedin/dustjs/pull/139) GH-85, GH-127 improve test coverage (@vybs) | ||
- [#127](https://github.com/linkedin/dustjs/pull/127) Fixed :else in section when iterating over empty array. (@zzen) | ||
- [#132](https://github.com/linkedin/dustjs/pull/132) Partial with parameters was not getting the correct context (@jimmyhchan) | ||
- [#108](https://github.com/linkedin/dustjs/pull/108) issue 106, accessing array inside a loop using the current context (@jairodemorais) | ||
- [#128](https://github.com/linkedin/dustjs/pull/128) Updated README for consistency and readability (@zzen) | ||
- [#126](https://github.com/linkedin/dustjs/pull/126) Removed left-over .DS_Store files (@zzen) | ||
- [#99](https://github.com/linkedin/dustjs/pull/99) new math helper method (@sclatter) | ||
- [#113](https://github.com/linkedin/dustjs/pull/113) Make $idx/$len work for all array objects and not leave old values in contexts (@rragan) | ||
- [#105](https://github.com/linkedin/dustjs/pull/105) merge PR https://github.com/linkedin/dustjs/pull/93 (@jairodemorais) | ||
- [#95](https://github.com/linkedin/dustjs/pull/95) helpers removed from Dust core. New npm package created for helpers. (@jairodemorais) | ||
### v1.0.0 (2012/07/04 19:08 +00:00) | ||
- [#78](https://github.com/linkedin/dustjs/pull/78) Use the tap method in the select helper (@jairodemorais) | ||
- [#65](https://github.com/linkedin/dustjs/pull/65) literal params relaxed to allow eol (@jairodemorais) | ||
- [#70](https://github.com/linkedin/dustjs/pull/70) fix issue https://github.com/linkedin/dustjs/issues/68 (@jairodemorais) | ||
- [#73](https://github.com/linkedin/dustjs/pull/73) dust resolve reference helper created and refactor if to use it (@jairodemorais) | ||
- [#71](https://github.com/linkedin/dustjs/pull/71) Test for pipe function added. (@jairodemorais, @kilianc) | ||
- [#56](https://github.com/linkedin/dustjs/pull/56) Fix for Issue #50: helper for debugging the context + console log wrapper (@jimmyhchan) | ||
- [#60](https://github.com/linkedin/dustjs/pull/60) dust moved to 0.6.0 version (@jairodemorais) | ||
- [#59](https://github.com/linkedin/dustjs/pull/59) ws relaxed to allow eol (@jairodemorais) | ||
- [#54](https://github.com/linkedin/dustjs/pull/54) preventing dust to crash on non existant if-condition (@seriousManual) | ||
- [#52](https://github.com/linkedin/dustjs/pull/52) Added unit test code coverage report with node-coverage (@jleppert) | ||
- [#44](https://github.com/linkedin/dustjs/pull/44) Select helper and unit tests, fixes #16 (@jleppert) | ||
- [#49](https://github.com/linkedin/dustjs/pull/49) dust tool included. (@jairodemorais) | ||
- [#40](https://github.com/linkedin/dustjs/pull/40) Rebuilding parser and merge to fix failed CI (@jleppert) | ||
- [#37](https://github.com/linkedin/dustjs/pull/37) Fixes #7, "Support numbers in the aliases" (@jleppert) | ||
- [#39](https://github.com/linkedin/dustjs/pull/39) Fixes #28, better error tracking implemented. (@jleppert) | ||
- [#31](https://github.com/linkedin/dustjs/pull/31) process.nextTick instead of setTimeout (@seriousManual) | ||
- [#34](https://github.com/linkedin/dustjs/pull/34) Escape a single quote apostrophe in escapeHtml (@jleppert) | ||
- [#36](https://github.com/linkedin/dustjs/pull/36) Rhino compatible (@jairodemorais) | ||
- [#13](https://github.com/linkedin/dustjs/pull/13) Issue #8 Support cleaner way to pass arguments to partials (@jimmyhchan) | ||
- [#25](https://github.com/linkedin/dustjs/pull/25) pegjs 0.7 compatibility and parser variables removed from section function on dustjs file (@jairodemorais) | ||
- [#9](https://github.com/linkedin/dustjs/pull/9) Update to 0.4.0 in dist so that docs are correct (@kmiyashiro) | ||
- [#5](https://github.com/linkedin/dustjs/pull/5) Quote 'if' helper, fixes #4 (@kmiyashiro) | ||
- [#3](https://github.com/linkedin/dustjs/pull/3) Gaurd against browsers (@Raynos) | ||
- [#5](https://github.com/linkedin/dustjs/pull/5) Quote 'if' helper, fixes #4 (@kmiyashiro) | ||
- [#9](https://github.com/linkedin/dustjs/pull/9) Update to 0.4.0 in dist so that docs are correct (@kmiyashiro) | ||
- [#25](https://github.com/linkedin/dustjs/pull/25) pegjs 0.7 compatibility and parser variables removed from section function on dustjs file (@jairodemorais) | ||
- [#13](https://github.com/linkedin/dustjs/pull/13) Issue #8 Support cleaner way to pass arguments to partials (@jimmyhchan) | ||
- [#36](https://github.com/linkedin/dustjs/pull/36) Rhino compatible (@jairodemorais) | ||
- [#34](https://github.com/linkedin/dustjs/pull/34) Escape a single quote apostrophe in escapeHtml (@iamleppert) | ||
- [#31](https://github.com/linkedin/dustjs/pull/31) process.nextTick instead of setTimeout (@zaphod1984) | ||
- [#39](https://github.com/linkedin/dustjs/pull/39) Fixes #28, better error tracking implemented. (@iamleppert) | ||
- [#37](https://github.com/linkedin/dustjs/pull/37) Fixes #7, "Support numbers in the aliases" (@iamleppert) | ||
- [#40](https://github.com/linkedin/dustjs/pull/40) Rebuilding parser and merge to fix failed CI (@iamleppert) | ||
- [#49](https://github.com/linkedin/dustjs/pull/49) dust tool included. (@jairodemorais) | ||
- [#44](https://github.com/linkedin/dustjs/pull/44) Select helper and unit tests, fixes #16 (@iamleppert) | ||
- [#52](https://github.com/linkedin/dustjs/pull/52) Added unit test code coverage report with node-coverage (@iamleppert) | ||
- [#54](https://github.com/linkedin/dustjs/pull/54) preventing dust to crash on non existant if-condition (@zaphod1984) | ||
- [#59](https://github.com/linkedin/dustjs/pull/59) ws relaxed to allow eol (@jairodemorais) | ||
- [#60](https://github.com/linkedin/dustjs/pull/60) dust moved to 0.6.0 version (@jairodemorais) | ||
- [#56](https://github.com/linkedin/dustjs/pull/56) Fix for Issue #50: helper for debugging the context + console log wrapper (@jimmyhchan) | ||
- [#71](https://github.com/linkedin/dustjs/pull/71) Test for pipe function added. (@jairodemorais, @kilianc) | ||
- [#73](https://github.com/linkedin/dustjs/pull/73) dust resolve reference helper created and refactor if to use it (@jairodemorais) | ||
- [#70](https://github.com/linkedin/dustjs/pull/70) fix issue https://github.com/linkedin/dustjs/issues/68 (@jairodemorais) | ||
- [#65](https://github.com/linkedin/dustjs/pull/65) literal params relaxed to allow eol (@jairodemorais) | ||
- [#78](https://github.com/linkedin/dustjs/pull/78) Use the tap method in the select helper (@jairodemorais) | ||
- [#95](https://github.com/linkedin/dustjs/pull/95) helpers removed from Dust core. New npm package created for helpers. (@jairodemorais) | ||
- [#105](https://github.com/linkedin/dustjs/pull/105) merge PR https://github.com/linkedin/dustjs/pull/93 (@jairodemorais) | ||
- [#113](https://github.com/linkedin/dustjs/pull/113) Make $idx/$len work for all array objects and not leave old values in contexts (@rragan) | ||
- [#99](https://github.com/linkedin/dustjs/pull/99) new math helper method (@sclatter) | ||
- [#126](https://github.com/linkedin/dustjs/pull/126) Removed left-over .DS_Store files (@zzen) | ||
- [#128](https://github.com/linkedin/dustjs/pull/128) Updated README for consistency and readability (@zzen) | ||
- [#108](https://github.com/linkedin/dustjs/pull/108) issue 106, accessing array inside a loop using the current context (@jairodemorais) | ||
- [#132](https://github.com/linkedin/dustjs/pull/132) Partial with parameters was not getting the correct context (@jimmyhchan) | ||
- [#127](https://github.com/linkedin/dustjs/pull/127) Fixed :else in section when iterating over empty array. (@zzen) | ||
- [#139](https://github.com/linkedin/dustjs/pull/139) GH-85, GH-127 improve test coverage (@vybs) | ||
- [#140](https://github.com/linkedin/dustjs/pull/140) GH-134 , remove support for scalar in the block # (@vybs) | ||
- [#141](https://github.com/linkedin/dustjs/pull/141) Fixes for GH-134 (@vybs) | ||
- [#142](https://github.com/linkedin/dustjs/pull/142) add another intersting test case with . and blocks (@vybs) | ||
- [#143](https://github.com/linkedin/dustjs/pull/143) reverse the GH-134 since it is backward incompatible (@vybs) | ||
- [#144](https://github.com/linkedin/dustjs/pull/144) minor: reorganized the section code and documented some more as to how t... (@vybs) | ||
- [#145](https://github.com/linkedin/dustjs/pull/145) rename grammar tests to core tests, since it testing dust.js core functionality, also has GH-133, fix the missing helper case (@vybs) | ||
- [#146](https://github.com/linkedin/dustjs/pull/146) Remove the old grammartests file, since it renamed to coreTests now and guard against missing context head in section (@vybs) | ||
- [#151](https://github.com/linkedin/dustjs/pull/151) add v1.1 files to the dist (@vybs) | ||
- [#152](https://github.com/linkedin/dustjs/pull/152) Really undo 2760048: removing scalar block support (@jimmyhchan) | ||
- [#156](https://github.com/linkedin/dustjs/pull/156) Cleanup the helpers from the dust repo, fix the make test (@vybs) | ||
- [#154](https://github.com/linkedin/dustjs/pull/154) partials with parameters context was missing blocks (@jimmyhchan) | ||
- [#157](https://github.com/linkedin/dustjs/pull/157) Add unit tests for the pull/154 (@vybs) | ||
- [#158](https://github.com/linkedin/dustjs/pull/158) fix the bad merge (@vybs) | ||
- [#159](https://github.com/linkedin/dustjs/pull/159) fix the description on the core tests for $idx and $len for scalar (@vybs) | ||
- [#165](https://github.com/linkedin/dustjs/pull/165) improve description in unit tests (@vybs) | ||
- [#168](https://github.com/linkedin/dustjs/pull/168) Minor README update (@sethmcl) | ||
- [#183](https://github.com/linkedin/dustjs/pull/183) cover, uglify and jasmine move to dev dependencies. GH-183 (@jairodemorais) | ||
- [#166](https://github.com/linkedin/dustjs/pull/166) Add template strip of white space to dust.compile (optional defaults to not strip) (@smfoote) | ||
- [#188](https://github.com/linkedin/dustjs/pull/188) The whitespace grammar rule for partial was a little inconsistent with other tags. issue GH=187 fixed. (@jairodemorais) | ||
- [#216](https://github.com/linkedin/dustjs/pull/216) add semicolons to dust compiler GH=215 (@jairodemorais) | ||
- [#223](https://github.com/linkedin/dustjs/pull/223) Fix for Issue #222. Code change + new test added to verify proper behavior (@rragan) | ||
- [#236](https://github.com/linkedin/dustjs/pull/236) eol added to buffer again. (@jairodemorais) | ||
- [#241](https://github.com/linkedin/dustjs/pull/241) using dust.isArray in place of Array.isArray (@jairodemorais) | ||
- [#243](https://github.com/linkedin/dustjs/pull/243) compiler variable name changed to dustCompiler (@jairodemorais) | ||
- [#245](https://github.com/linkedin/dustjs/pull/245) Gh-208 - solve the incorrect error line reported in peg (@jairodemorais) | ||
- [#249](https://github.com/linkedin/dustjs/pull/249) Remove debugger in dust-full-1.2.1.js (@sethkinast) | ||
- [#253](https://github.com/linkedin/dustjs/pull/253) 2-3000% performance enhancement in IE7 (@jlkonsultab) | ||
- [#263](https://github.com/linkedin/dustjs/pull/263) Add forward slash and unit tests for j filter (@prashn64) | ||
- [#274](https://github.com/linkedin/dustjs/pull/274) GH-266 store rendered template in global (@vybs) | ||
- [#25](https://github.com/linkedin/dustjs/pull/25) process.binding('evals') is now require('vm') (@stonecobra) |
@@ -1,21 +0,20 @@ | ||
/*! Dust - Asynchronous Templating - v2.6.1 | ||
/*! Dust - Asynchronous Templating - v2.6.2 | ||
* http://linkedin.github.io/dustjs/ | ||
* Copyright (c) 2015 Aleksander Williams; Released under the MIT License */ | ||
(function(root) { | ||
(function (root, factory) { | ||
/*global define*/ | ||
if (typeof define === 'function' && define.amd && define.amd.dust === true) { | ||
define('dust.core', [], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(); | ||
} else { | ||
root.dust = factory(); | ||
} | ||
}(this, function() { | ||
var dust = { | ||
"version": "2.6.1" | ||
"version": "2.6.2" | ||
}, | ||
NONE = 'NONE', | ||
ERROR = 'ERROR', | ||
WARN = 'WARN', | ||
INFO = 'INFO', | ||
DEBUG = 'DEBUG', | ||
loggingLevels = [DEBUG, INFO, WARN, ERROR, NONE], | ||
EMPTY_FUNC = function() {}, | ||
logger = {}, | ||
originalLog, | ||
loggerContext; | ||
NONE = 'NONE', ERROR = 'ERROR', WARN = 'WARN', INFO = 'INFO', DEBUG = 'DEBUG', | ||
EMPTY_FUNC = function() {}; | ||
dust.debugLevel = NONE; | ||
dust.config = { | ||
@@ -41,44 +40,44 @@ whitespace: false, | ||
// Try to find the console in global scope | ||
if (root && root.console && root.console.log) { | ||
loggerContext = root.console; | ||
originalLog = root.console.log; | ||
} | ||
(function initLogging() { | ||
/*global process, console*/ | ||
var loggingLevels = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, NONE: 4 }, | ||
consoleLog, | ||
log; | ||
// robust logger for node.js, modern browsers, and IE <= 9. | ||
logger.log = loggerContext ? function() { | ||
// Do this for normal browsers | ||
if (typeof originalLog === 'function') { | ||
logger.log = function() { | ||
originalLog.apply(loggerContext, arguments); | ||
if (typeof console !== 'undefined' && console.log) { | ||
consoleLog = console.log; | ||
if(typeof consoleLog === 'function') { | ||
log = function() { | ||
consoleLog.apply(console, arguments); | ||
}; | ||
} else { | ||
// Do this for IE <= 9 | ||
logger.log = function() { | ||
var message = Array.prototype.slice.apply(arguments).join(' '); | ||
originalLog(message); | ||
log = function() { | ||
consoleLog(Array.prototype.slice.apply(arguments).join(' ')); | ||
}; | ||
} | ||
logger.log.apply(this, arguments); | ||
} : function() { /* no op */ }; | ||
} else { | ||
log = EMPTY_FUNC; | ||
} | ||
/** | ||
* Log dust debug statements, info statements, warning statements, and errors. | ||
* Filters out the messages based on the dust.debuglevel. | ||
* This default implementation will print to the console if it exists. | ||
* @param {String|Error} message the message to print/throw | ||
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG) | ||
* @public | ||
*/ | ||
dust.log = function(message, type) { | ||
type = type || INFO; | ||
if (dust.debugLevel !== NONE && dust.indexInArray(loggingLevels, type) >= dust.indexInArray(loggingLevels, dust.debugLevel)) { | ||
if(!dust.logQueue) { | ||
dust.logQueue = []; | ||
/** | ||
* Filters messages based on `dust.debugLevel`. | ||
* This default implementation will print to the console if it exists. | ||
* @param {String|Error} message the message to print/throw | ||
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG) | ||
* @public | ||
*/ | ||
dust.log = function(message, type) { | ||
type = type || INFO; | ||
if (loggingLevels[type] >= loggingLevels[dust.debugLevel]) { | ||
log('[DUST:' + type + ']', message); | ||
} | ||
dust.logQueue.push({message: message, type: type}); | ||
logger.log('[DUST:' + type + ']', message); | ||
}; | ||
dust.debugLevel = NONE; | ||
if(typeof process !== 'undefined' && process.env && /\bdust\b/.test(process.env.DEBUG)) { | ||
dust.debugLevel = DEBUG; | ||
} | ||
}; | ||
}()); | ||
dust.helpers = {}; | ||
@@ -121,5 +120,10 @@ | ||
/** | ||
* Compile a template to an invokable function. | ||
* If `name` is provided, also registers the template under `name`. | ||
* @param source {String} template source | ||
* @param [name] {String} template name | ||
* @return {Function} has the signature `fn(context, cb)` | ||
*/ | ||
dust.compileFn = function(source, name) { | ||
// name is optional. When name is not provided the template can only be rendered using the callable returned by this function. | ||
// If a name is provided the compiled template can also be rendered by name. | ||
name = name || null; | ||
@@ -132,6 +136,5 @@ var tmpl = dust.loadSource(dust.compile(source, name)); | ||
tmpl(master.head, Context.wrap(context, name)).end(); | ||
} else { | ||
dust.log(new Error('Template `' + name + '` could not be loaded'), ERROR); | ||
} | ||
else { | ||
dust.log(new Error('Template [' + name + '] cannot be resolved to a Dust function'), ERROR); | ||
} | ||
}); | ||
@@ -165,2 +168,3 @@ return master; | ||
dust.loadSource = function(source, path) { | ||
/*jshint evil:true*/ | ||
return eval(source); | ||
@@ -177,36 +181,2 @@ }; | ||
// indexOf shim for arrays for IE <= 8 | ||
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf | ||
dust.indexInArray = function(arr, item, fromIndex) { | ||
fromIndex = +fromIndex || 0; | ||
if (Array.prototype.indexOf) { | ||
return arr.indexOf(item, fromIndex); | ||
} else { | ||
if ( arr === undefined || arr === null ) { | ||
throw new TypeError( 'cannot call method "indexOf" of null' ); | ||
} | ||
var length = arr.length; // Hack to convert object.length to a UInt32 | ||
if (Math.abs(fromIndex) === Infinity) { | ||
fromIndex = 0; | ||
} | ||
if (fromIndex < 0) { | ||
fromIndex += length; | ||
if (fromIndex < 0) { | ||
fromIndex = 0; | ||
} | ||
} | ||
for (;fromIndex < length; fromIndex++) { | ||
if (arr[fromIndex] === item) { | ||
return fromIndex; | ||
} | ||
} | ||
return -1; | ||
} | ||
}; | ||
dust.nextTick = (function() { | ||
@@ -218,17 +188,52 @@ return function(callback) { | ||
/** | ||
* Dust has its own rules for what is "empty"-- which is not the same as falsy. | ||
* Empty arrays, null, and undefined are empty | ||
*/ | ||
dust.isEmpty = function(value) { | ||
if (value === 0) { | ||
return false; | ||
} | ||
if (dust.isArray(value) && !value.length) { | ||
return true; | ||
} | ||
if (value === 0) { | ||
return !value; | ||
}; | ||
dust.isEmptyObject = function(obj) { | ||
var key; | ||
if (obj === null) { | ||
return false; | ||
} | ||
return (!value); | ||
if (obj === undefined) { | ||
return false; | ||
} | ||
if (obj.length > 0) { | ||
return false; | ||
} | ||
for (key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Decide somewhat-naively if something is a Thenable. | ||
* @param elem {*} object to inspect | ||
* @return {Boolean} is `elem` a Thenable? | ||
*/ | ||
dust.isThenable = function(elem) { | ||
return elem && | ||
typeof elem === 'object' && | ||
typeof elem.then === 'function'; | ||
}; | ||
// apply the filter chain and return the output string | ||
dust.filter = function(string, auto, filters) { | ||
var i, len, name; | ||
if (filters) { | ||
for (var i=0, len=filters.length; i<len; i++) { | ||
var name = filters[i]; | ||
for (i = 0, len = filters.length; i < len; i++) { | ||
name = filters[i]; | ||
if (name === 's') { | ||
@@ -241,3 +246,3 @@ auto = null; | ||
else { | ||
dust.log('Invalid filter [' + name + ']', WARN); | ||
dust.log('Invalid filter `' + name + '`', WARN); | ||
} | ||
@@ -260,3 +265,3 @@ } | ||
jp: function(value) { | ||
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN); | ||
if (!JSON) {dust.log('JSON is undefined; could not parse `' + value + '`', WARN); | ||
return value; | ||
@@ -270,3 +275,3 @@ } else { | ||
function Context(stack, global, blocks, templateName) { | ||
this.stack = stack; | ||
this.stack = stack; | ||
this.global = global; | ||
@@ -281,2 +286,14 @@ this.blocks = blocks; | ||
/** | ||
* Factory function that creates a closure scope around a Thenable-callback. | ||
* Returns a function that can be passed to a Thenable that will resume a | ||
* Context lookup once the Thenable resolves with new data, adding that new | ||
* data to the lookup stack. | ||
*/ | ||
function getWithResolvedData(ctx, cur, down) { | ||
return function(data) { | ||
return ctx.push(data)._get(cur, down); | ||
}; | ||
} | ||
Context.wrap = function(context, name) { | ||
@@ -323,5 +340,6 @@ if (context instanceof Context) { | ||
Context.prototype._get = function(cur, down) { | ||
var ctx = this.stack, | ||
var ctx = this.stack || {}, | ||
i = 1, | ||
value, first, len, ctxThis, fn; | ||
first = down[0]; | ||
@@ -357,3 +375,3 @@ len = down.length; | ||
} else { | ||
//context's head is empty, value we are searching for is not defined | ||
// context's head is empty, value we are searching for is not defined | ||
ctx = undefined; | ||
@@ -364,2 +382,6 @@ } | ||
while (ctx && i < len) { | ||
if (dust.isThenable(ctx)) { | ||
// Bail early by returning a Thenable for the remainder of the search tree | ||
return ctx.then(getWithResolvedData(this, cur, down.slice(i))); | ||
} | ||
ctxThis = ctx; | ||
@@ -371,3 +393,2 @@ ctx = ctx[down[i]]; | ||
// Return the ctx or a function wrapping the application of the context. | ||
if (typeof ctx === 'function') { | ||
@@ -386,3 +407,3 @@ fn = function() { | ||
if (ctx === undefined) { | ||
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']'); | ||
dust.log('Cannot find reference `{' + down.join('.') + '}` in template `' + this.getTemplateName() + '`', INFO); | ||
} | ||
@@ -401,2 +422,8 @@ return ctx; | ||
Context.prototype.pop = function() { | ||
var head = this.current(); | ||
this.stack = this.stack && this.stack.tail; | ||
return head; | ||
}; | ||
Context.prototype.rebase = function(head) { | ||
@@ -406,19 +433,27 @@ return new Context(new Stack(head), this.global, this.blocks, this.getTemplateName()); | ||
Context.prototype.clone = function() { | ||
var context = this.rebase(); | ||
context.stack = this.stack; | ||
return context; | ||
}; | ||
Context.prototype.current = function() { | ||
return this.stack.head; | ||
return this.stack && this.stack.head; | ||
}; | ||
Context.prototype.getBlock = function(key, chk, ctx) { | ||
var blocks, len, fn; | ||
if (typeof key === 'function') { | ||
var tempChk = new Chunk(); | ||
key = key(tempChk, this).data.join(''); | ||
key = key(new Chunk(), this).data.join(''); | ||
} | ||
var blocks = this.blocks; | ||
blocks = this.blocks; | ||
if (!blocks) { | ||
dust.log('No blocks for context[{' + key + '}] in template [' + this.getTemplateName() + ']', DEBUG); | ||
return; | ||
dust.log('No blocks for context `' + key + '` in template `' + this.getTemplateName() + '`', DEBUG); | ||
return false; | ||
} | ||
var len = blocks.length, fn; | ||
len = blocks.length; | ||
while (len--) { | ||
@@ -430,2 +465,5 @@ fn = blocks[len][key]; | ||
} | ||
dust.log('Malformed template `' + this.getTemplateName() + '` was missing one or more blocks.'); | ||
return false; | ||
}; | ||
@@ -448,2 +486,15 @@ | ||
Context.prototype.resolve = function(body) { | ||
var chunk; | ||
if(typeof body !== 'function') { | ||
return body; | ||
} | ||
chunk = new Chunk().render(body, this); | ||
if(!body.__dustBody) { | ||
return chunk; | ||
} | ||
return chunk.data.join(''); // ie7 perf | ||
}; | ||
Context.prototype.getTemplateName = function() { | ||
@@ -475,3 +526,3 @@ return this.templateName; | ||
this.callback(chunk.error); | ||
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN); | ||
dust.log('Rendering failed with error `' + chunk.error + '`', ERROR); | ||
this.flush = EMPTY_FUNC; | ||
@@ -500,3 +551,3 @@ return; | ||
this.emit('error', chunk.error); | ||
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN); | ||
dust.log('Streaming failed with error `' + chunk.error + '`', ERROR); | ||
this.flush = EMPTY_FUNC; | ||
@@ -514,37 +565,25 @@ return; | ||
Stream.prototype.emit = function(type, data) { | ||
if (!this.events) { | ||
dust.log('No events to emit', INFO); | ||
return false; | ||
var events = this.events || {}, | ||
handlers = events[type] || [], | ||
i, l; | ||
if (!handlers.length) { | ||
dust.log('Stream broadcasting, but no listeners for `' + type + '`', DEBUG); | ||
return; | ||
} | ||
var handler = this.events[type]; | ||
if (!handler) { | ||
dust.log('Event type [' + type + '] does not exist', WARN); | ||
return false; | ||
handlers = handlers.slice(0); | ||
for (i = 0, l = handlers.length; i < l; i++) { | ||
handlers[i](data); | ||
} | ||
if (typeof handler === 'function') { | ||
handler(data); | ||
} else if (dust.isArray(handler)) { | ||
var listeners = handler.slice(0); | ||
for (var i = 0, l = listeners.length; i < l; i++) { | ||
listeners[i](data); | ||
} | ||
} else { | ||
dust.log('Event Handler [' + handler + '] is not of a type that is handled by emit', WARN); | ||
} | ||
}; | ||
Stream.prototype.on = function(type, callback) { | ||
if (!this.events) { | ||
this.events = {}; | ||
} | ||
if (!this.events[type]) { | ||
if(callback) { | ||
this.events[type] = callback; | ||
} else { | ||
dust.log('Callback for type [' + type + '] does not exist. Listener not registered.', WARN); | ||
} | ||
} else if(typeof this.events[type] === 'function') { | ||
this.events[type] = [this.events[type], callback]; | ||
var events = this.events = this.events || {}, | ||
handlers = events[type] = events[type] || []; | ||
if(typeof callback !== 'function') { | ||
dust.log('No callback function provided for `' + type + '` event listener', WARN); | ||
} else { | ||
this.events[type].push(callback); | ||
handlers.push(callback); | ||
} | ||
@@ -555,3 +594,4 @@ return this; | ||
Stream.prototype.pipe = function(stream) { | ||
this.on('data', function(data) { | ||
return this | ||
.on('data', function(data) { | ||
try { | ||
@@ -562,12 +602,13 @@ stream.write(data, 'utf8'); | ||
} | ||
}).on('end', function() { | ||
}) | ||
.on('end', function() { | ||
try { | ||
return stream.end(); | ||
stream.end(); | ||
} catch (err) { | ||
dust.log(err, ERROR); | ||
} | ||
}).on('error', function(err) { | ||
}) | ||
.on('error', function(err) { | ||
stream.error(err); | ||
}); | ||
return this; | ||
}; | ||
@@ -584,3 +625,3 @@ | ||
Chunk.prototype.write = function(data) { | ||
var taps = this.taps; | ||
var taps = this.taps; | ||
@@ -611,5 +652,5 @@ if (taps) { | ||
callback(branch); | ||
} catch(e) { | ||
dust.log(e, ERROR); | ||
branch.setError(e); | ||
} catch(err) { | ||
dust.log(err, ERROR); | ||
branch.setError(err); | ||
} | ||
@@ -641,4 +682,2 @@ return cursor; | ||
if (typeof elem === 'function') { | ||
// Changed the function calling to use apply with the current context to make sure | ||
// that "this" is wat we expect it to be inside the function | ||
elem = elem.apply(context.current(), [this, context, null, {auto: auto, filters: filters}]); | ||
@@ -649,3 +688,5 @@ if (elem instanceof Chunk) { | ||
} | ||
if (!dust.isEmpty(elem)) { | ||
if (dust.isThenable(elem)) { | ||
return this.await(elem, context); | ||
} else if (!dust.isEmpty(elem)) { | ||
return this.write(dust.filter(elem, auto, filters)); | ||
@@ -658,12 +699,16 @@ } else { | ||
Chunk.prototype.section = function(elem, context, bodies, params) { | ||
// anonymous functions | ||
var body = bodies.block, | ||
skip = bodies['else'], | ||
chunk = this, | ||
i, len; | ||
if (typeof elem === 'function' && !elem.__dustBody) { | ||
try { | ||
elem = elem.apply(context.current(), [this, context, bodies, params]); | ||
} catch(e) { | ||
dust.log(e, ERROR); | ||
return this.setError(e); | ||
} catch(err) { | ||
dust.log(err, ERROR); | ||
return this.setError(err); | ||
} | ||
// 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 | ||
// Functions that return chunks are assumed to have handled the chunk manually. | ||
// Make that chunk the current one and go to the next method in the chain. | ||
if (elem instanceof Chunk) { | ||
@@ -673,7 +718,4 @@ return elem; | ||
} | ||
var body = bodies.block, | ||
skip = bodies['else']; | ||
// a.k.a Inline parameters in the Dust documentations | ||
if (params) { | ||
if (!dust.isEmptyObject(params)) { | ||
context = context.push(params); | ||
@@ -687,13 +729,11 @@ } | ||
*/ | ||
//non empty array is truthy, empty array is falsy | ||
if (dust.isArray(elem)) { | ||
if (body) { | ||
var len = elem.length, chunk = this; | ||
len = elem.length; | ||
if (len > 0) { | ||
// any custom helper can blow up the stack | ||
// and store a flattened context, guard defensively | ||
// any custom helper can blow up the stack and store a flattened context, guard defensively | ||
if(context.stack.head) { | ||
context.stack.head['$len'] = len; | ||
} | ||
for (var i=0; i<len; i++) { | ||
for (i = 0; i < len; i++) { | ||
if(context.stack.head) { | ||
@@ -714,3 +754,5 @@ context.stack.head['$idx'] = i; | ||
} | ||
} else if (elem === true) { | ||
} else if (dust.isThenable(elem)) { | ||
return this.await(elem, context, bodies); | ||
} else if (elem === true) { | ||
// true is truthy but does not change context | ||
@@ -732,3 +774,3 @@ if (body) { | ||
} | ||
dust.log('Not rendering section (#) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG); | ||
dust.log('Section without corresponding key in template `' + context.getTemplateName() + '`', DEBUG); | ||
return this; | ||
@@ -745,6 +787,6 @@ }; | ||
} | ||
dust.log('No block for exists check in template `' + context.getTemplateName() + '`', DEBUG); | ||
} else if (skip) { | ||
return skip(this, context); | ||
} | ||
dust.log('Not rendering exists (?) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG); | ||
return this; | ||
@@ -761,6 +803,6 @@ }; | ||
} | ||
dust.log('No block for not-exists check in template `' + context.getTemplateName() + '`', DEBUG); | ||
} else if (skip) { | ||
return skip(this, context); | ||
} | ||
dust.log('Not rendering not exists (^) block check in template [' + context.getTemplateName() + '], because above key was found', DEBUG); | ||
return this; | ||
@@ -770,8 +812,4 @@ }; | ||
Chunk.prototype.block = function(elem, context, bodies) { | ||
var body = bodies.block; | ||
var body = elem || bodies.block; | ||
if (elem) { | ||
body = elem; | ||
} | ||
if (body) { | ||
@@ -784,47 +822,41 @@ return body(this, context); | ||
Chunk.prototype.partial = function(elem, context, params) { | ||
var partialContext; | ||
//put the params context second to match what section does. {.} matches the current context without parameters | ||
// start with an empty context | ||
partialContext = dust.makeBase(context.global); | ||
partialContext.blocks = context.blocks; | ||
if (context.stack && context.stack.tail){ | ||
// grab the stack(tail) off of the previous context if we have it | ||
partialContext.stack = context.stack.tail; | ||
} | ||
if (params){ | ||
//put params on | ||
partialContext = partialContext.push(params); | ||
} | ||
var head; | ||
if(typeof elem === 'string') { | ||
partialContext.templateName = elem; | ||
if (!dust.isEmptyObject(params)) { | ||
context = context.clone(); | ||
head = context.pop(); | ||
context = context.push(params) | ||
.push(head); | ||
} | ||
//reattach the head | ||
partialContext = partialContext.push(context.stack.head); | ||
var partialChunk; | ||
if (typeof elem === 'function') { | ||
partialChunk = this.capture(elem, partialContext, function(name, chunk) { | ||
partialContext.templateName = partialContext.templateName || name; | ||
dust.load(name, chunk, partialContext).end(); | ||
if (elem.__dustBody) { | ||
// The eventual result of evaluating `elem` is a partial name | ||
// Load the partial after getting its name and end the async chunk | ||
return this.capture(elem, context, function(name, chunk) { | ||
context.templateName = name; | ||
dust.load(name, chunk, context).end(); | ||
}); | ||
} else { | ||
partialChunk = dust.load(elem, this, partialContext); | ||
context.templateName = elem; | ||
return dust.load(elem, this, context); | ||
} | ||
return partialChunk; | ||
}; | ||
Chunk.prototype.helper = function(name, context, bodies, params) { | ||
var chunk = this; | ||
var chunk = this, | ||
ret; | ||
// handle invalid helpers, similar to invalid filters | ||
if(dust.helpers[name]) { | ||
try { | ||
return dust.helpers[name](chunk, context, bodies, params); | ||
} catch(e) { | ||
dust.log('Error in ' + name + ' helper: ' + e, ERROR); | ||
return chunk.setError(e); | ||
ret = dust.helpers[name](chunk, context, bodies, params); | ||
if (dust.isThenable(ret)) { | ||
return this.await(ret, context, bodies); | ||
} | ||
return ret; | ||
} catch(err) { | ||
dust.log('Error in helper `' + name + '`: ' + err.message, ERROR); | ||
return chunk.setError(err); | ||
} | ||
} else { | ||
dust.log('Invalid helper [' + name + ']', WARN); | ||
dust.log('Helper `' + name + '` does not exist', WARN); | ||
return chunk; | ||
@@ -834,2 +866,30 @@ } | ||
/** | ||
* Reserve a chunk to be evaluated once a thenable is resolved or rejected | ||
* @param thenable {Thenable} the target thenable to await | ||
* @param context {Context} context to use to render the deferred chunk | ||
* @param bodies {Object} must contain a "body", may contain an "error" | ||
* @return {Chunk} | ||
*/ | ||
Chunk.prototype.await = function(thenable, context, bodies) { | ||
var body = bodies && bodies.block, | ||
errorBody = bodies && bodies.error; | ||
return this.map(function(chunk) { | ||
thenable.then(function(data) { | ||
if(body) { | ||
chunk.render(body, context.push(data)).end(); | ||
} else { | ||
chunk.end(data); | ||
} | ||
}, function(err) { | ||
if(errorBody) { | ||
chunk.render(errorBody, context.push(err)).end(); | ||
} else { | ||
dust.log('Unhandled promise rejection in `' + context.getTemplateName() + '`'); | ||
chunk.end(); | ||
} | ||
}); | ||
}); | ||
}; | ||
Chunk.prototype.capture = function(body, context, callback) { | ||
@@ -930,3 +990,3 @@ return this.map(function(chunk) { | ||
if (!JSON) { | ||
dust.log('JSON is undefined. JSON stringify has not been used on [' + o + ']', WARN); | ||
dust.log('JSON is undefined; could not escape `' + o + '`', WARN); | ||
return o; | ||
@@ -941,13 +1001,5 @@ } else { | ||
if (typeof define === "function" && define.amd && define.amd.dust === true) { | ||
define("dust.core", function() { | ||
return dust; | ||
}); | ||
} else if (typeof exports === 'object') { | ||
module.exports = dust; | ||
} else { | ||
root.dust = dust; | ||
} | ||
return dust; | ||
})((function(){return this;})()); | ||
})); | ||
@@ -954,0 +1006,0 @@ if (typeof define === "function" && define.amd && define.amd.dust === true) { |
@@ -1,4 +0,4 @@ | ||
/*! Dust - Asynchronous Templating - v2.6.1 | ||
/*! Dust - Asynchronous Templating - v2.6.2 | ||
* http://linkedin.github.io/dustjs/ | ||
* Copyright (c) 2015 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={version:"2.6.1"},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,dust.config={whitespace:!1,amd:!1},dust._aliases={write:"w",end:"e",map:"m",render:"r",reference:"f",section:"s",exists:"x",notexists:"nx",block:"b",partial:"p",helper:"h"},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(Math.abs(c)===1/0&&(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 dust.escapeJSON(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,h=this.stack,i=1;if(d=b[0],e=b.length,a&&0===e)f=h,h=h.head;else{if(a)h&&(h=h.head?h.head[d]:void 0);else{for(;h&&(!h.isObject||(f=h.head,c=h.head[d],void 0===c));)h=h.tail;h=void 0!==c?c:this.global?this.global[d]:void 0}for(;h&&e>i;)f=h,h=h[b[i]],i++}return"function"==typeof h?(g=function(){try{return h.apply(f,arguments)}catch(a){throw dust.log(a,ERROR),a}},g.__dustBody=!!h.__dustBody,g):(void 0===h&&dust.log("Cannot find the value for reference [{"+b.join(".")+"}] in template ["+this.getTemplateName()+"]"),h)},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):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&&!a.__dustBody){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};for(var f in Chunk.prototype)dust._aliases[f]&&(Chunk.prototype[dust._aliases[f]]=Chunk.prototype[f]);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=/[&<>"']/,AMP=/&/g,LT=/</g,GT=/>/g,QUOT=/\"/g,SQUOT=/\'/g;dust.escapeHtml=function(a){return"string"==typeof a||a&&"function"==typeof a.toString?("string"!=typeof a&&(a=a.toString()),HCHARS.test(a)?a.replace(AMP,"&").replace(LT,"<").replace(GT,">").replace(QUOT,""").replace(SQUOT,"'"):a):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},dust.escapeJSON=function(a){return JSON?JSON.stringify(a).replace(LS,"\\u2028").replace(PS,"\\u2029").replace(LT,"\\u003c"):(dust.log("JSON is undefined. JSON stringify has not been used on ["+a+"]",WARN),a)},"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.core",function(){return dust}):"object"==typeof exports?module.exports=dust:root.dust=dust}(function(){return this}()),"function"==typeof define&&define.amd&&define.amd.dust===!0&&define(["require","dust.core"],function(require,dust){return dust.onLoad=function(a,b){require([a],function(){b()})},dust}); | ||
!function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.core",[],b):"object"==typeof exports?module.exports=b():a.dust=b()}(this,function(){function Context(a,b,c,d){this.stack=a,this.global=b,this.blocks=c,this.templateName=d}function getWithResolvedData(a,b,c){return function(d){return a.push(d)._get(b,c)}}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={version:"2.6.2"},NONE="NONE",ERROR="ERROR",WARN="WARN",INFO="INFO",DEBUG="DEBUG",EMPTY_FUNC=function(){};dust.config={whitespace:!1,amd:!1},dust._aliases={write:"w",end:"e",map:"m",render:"r",reference:"f",section:"s",exists:"x",notexists:"nx",block:"b",partial:"p",helper:"h"},function(){var a,b,c={DEBUG:0,INFO:1,WARN:2,ERROR:3,NONE:4};"undefined"!=typeof console&&console.log?(a=console.log,b="function"==typeof a?function(){a.apply(console,arguments)}:function(){a(Array.prototype.slice.apply(arguments).join(" "))}):b=EMPTY_FUNC,dust.log=function(a,d){d=d||INFO,c[d]>=c[dust.debugLevel]&&b("[DUST:"+d+"]",a)},dust.debugLevel=NONE,"undefined"!=typeof process&&process.env&&/\bdust\b/.test(process.env.DEBUG)&&(dust.debugLevel=DEBUG)}(),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+"` could not be loaded"),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.nextTick=function(){return function(a){setTimeout(a,0)}}(),dust.isEmpty=function(a){return 0===a?!1:dust.isArray(a)&&!a.length?!0:!a},dust.isEmptyObject=function(a){var b;if(null===a)return!1;if(void 0===a)return!1;if(a.length>0)return!1;for(b in a)if(Object.prototype.hasOwnProperty.call(a,b))return!1;return!0},dust.isThenable=function(a){return a&&"object"==typeof a&&"function"==typeof a.then},dust.filter=function(a,b,c){var d,e,f;if(c)for(d=0,e=c.length;e>d;d++)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 dust.escapeJSON(a)},jp:function(a){return JSON?JSON.parse(a):(dust.log("JSON is undefined; could not parse `"+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,h=this.stack||{},i=1;if(d=b[0],e=b.length,a&&0===e)f=h,h=h.head;else{if(a)h&&(h=h.head?h.head[d]:void 0);else{for(;h&&(!h.isObject||(f=h.head,c=h.head[d],void 0===c));)h=h.tail;h=void 0!==c?c:this.global?this.global[d]:void 0}for(;h&&e>i;){if(dust.isThenable(h))return h.then(getWithResolvedData(this,a,b.slice(i)));f=h,h=h[b[i]],i++}}return"function"==typeof h?(g=function(){try{return h.apply(f,arguments)}catch(a){throw dust.log(a,ERROR),a}},g.__dustBody=!!h.__dustBody,g):(void 0===h&&dust.log("Cannot find reference `{"+b.join(".")+"}` in template `"+this.getTemplateName()+"`",INFO),h)},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.pop=function(){var a=this.current();return this.stack=this.stack&&this.stack.tail,a},Context.prototype.rebase=function(a){return new Context(new Stack(a),this.global,this.blocks,this.getTemplateName())},Context.prototype.clone=function(){var a=this.rebase();return a.stack=this.stack,a},Context.prototype.current=function(){return this.stack&&this.stack.head},Context.prototype.getBlock=function(a){var b,c,d;if("function"==typeof a&&(a=a(new Chunk,this).data.join("")),b=this.blocks,!b)return dust.log("No blocks for context `"+a+"` in template `"+this.getTemplateName()+"`",DEBUG),!1;for(c=b.length;c--;)if(d=b[c][a])return d;return dust.log("Malformed template `"+this.getTemplateName()+"` was missing one or more blocks."),!1},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.resolve=function(a){var b;return"function"!=typeof a?a:(b=(new Chunk).render(a,this),a.__dustBody?b.data.join(""):b)},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("Rendering failed with error `"+a.error+"`",ERROR),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("Streaming failed with error `"+a.error+"`",ERROR),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){var c,d,e=this.events||{},f=e[a]||[];if(!f.length)return void dust.log("Stream broadcasting, but no listeners for `"+a+"`",DEBUG);for(f=f.slice(0),c=0,d=f.length;d>c;c++)f[c](b)},Stream.prototype.on=function(a,b){var c=this.events=this.events||{},d=c[a]=c[a]||[];return"function"!=typeof b?dust.log("No callback function provided for `"+a+"` event listener",WARN):d.push(b),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{a.end()}catch(b){dust.log(b,ERROR)}}).on("error",function(b){a.error(b)})},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.isThenable(a)?this.await(a,b):dust.isEmpty(a)?this:this.write(dust.filter(a,c,d))},Chunk.prototype.section=function(a,b,c,d){var e,f,g=c.block,h=c["else"],i=this;if("function"==typeof a&&!a.__dustBody){try{a=a.apply(b.current(),[this,b,c,d])}catch(j){return dust.log(j,ERROR),this.setError(j)}if(a instanceof Chunk)return a}if(dust.isEmptyObject(d)||(b=b.push(d)),dust.isArray(a)){if(g){if(f=a.length,f>0){for(b.stack.head&&(b.stack.head.$len=f),e=0;f>e;e++)b.stack.head&&(b.stack.head.$idx=e),i=g(i,b.push(a[e],e,f));return b.stack.head&&(b.stack.head.$idx=void 0,b.stack.head.$len=void 0),i}if(h)return h(this,b)}}else{if(dust.isThenable(a))return this.await(a,b,c);if(a===!0){if(g)return g(this,b)}else if(a||0===a){if(g)return g(this,b.push(a))}else if(h)return h(this,b)}return dust.log("Section without corresponding key in template `"+b.getTemplateName()+"`",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);dust.log("No block for exists check in template `"+b.getTemplateName()+"`",DEBUG)}return 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);dust.log("No block for not-exists check in template `"+b.getTemplateName()+"`",DEBUG)}else if(e)return e(this,b);return this},Chunk.prototype.block=function(a,b,c){var d=a||c.block;return d?d(this,b):this},Chunk.prototype.partial=function(a,b,c){var d;return dust.isEmptyObject(c)||(b=b.clone(),d=b.pop(),b=b.push(c).push(d)),a.__dustBody?this.capture(a,b,function(a,c){b.templateName=a,dust.load(a,c,b).end()}):(b.templateName=a,dust.load(a,this,b))},Chunk.prototype.helper=function(a,b,c,d){var e,f=this;if(!dust.helpers[a])return dust.log("Helper `"+a+"` does not exist",WARN),f;try{return e=dust.helpers[a](f,b,c,d),dust.isThenable(e)?this.await(e,b,c):e}catch(g){return dust.log("Error in helper `"+a+"`: "+g.message,ERROR),f.setError(g)}},Chunk.prototype.await=function(a,b,c){var d=c&&c.block,e=c&&c.error;return this.map(function(c){a.then(function(a){d?c.render(d,b.push(a)).end():c.end(a)},function(a){e?c.render(e,b.push(a)).end():(dust.log("Unhandled promise rejection in `"+b.getTemplateName()+"`"),c.end())})})},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};for(var f in Chunk.prototype)dust._aliases[f]&&(Chunk.prototype[dust._aliases[f]]=Chunk.prototype[f]);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=/[&<>"']/,AMP=/&/g,LT=/</g,GT=/>/g,QUOT=/\"/g,SQUOT=/\'/g;dust.escapeHtml=function(a){return"string"==typeof a||a&&"function"==typeof a.toString?("string"!=typeof a&&(a=a.toString()),HCHARS.test(a)?a.replace(AMP,"&").replace(LT,"<").replace(GT,">").replace(QUOT,""").replace(SQUOT,"'"):a):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;return 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},dust.escapeJSON=function(a){return JSON?JSON.stringify(a).replace(LS,"\\u2028").replace(PS,"\\u2029").replace(LT,"\\u003c"):(dust.log("JSON is undefined; could not escape `"+a+"`",WARN),a)},dust}),"function"==typeof define&&define.amd&&define.amd.dust===!0&&define(["require","dust.core"],function(require,dust){return dust.onLoad=function(a,b){require([a],function(){b()})},dust}); |
@@ -1,5 +0,5 @@ | ||
/*! Dust - Asynchronous Templating - v2.6.1 | ||
/*! Dust - Asynchronous Templating - v2.6.2 | ||
* http://linkedin.github.io/dustjs/ | ||
* Copyright (c) 2015 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={version:"2.6.1"},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,dust.config={whitespace:!1,amd:!1},dust._aliases={write:"w",end:"e",map:"m",render:"r",reference:"f",section:"s",exists:"x",notexists:"nx",block:"b",partial:"p",helper:"h"},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(Math.abs(c)===1/0&&(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 dust.escapeJSON(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,h=this.stack,i=1;if(d=b[0],e=b.length,a&&0===e)f=h,h=h.head;else{if(a)h&&(h=h.head?h.head[d]:void 0);else{for(;h&&(!h.isObject||(f=h.head,c=h.head[d],void 0===c));)h=h.tail;h=void 0!==c?c:this.global?this.global[d]:void 0}for(;h&&e>i;)f=h,h=h[b[i]],i++}return"function"==typeof h?(g=function(){try{return h.apply(f,arguments)}catch(a){throw dust.log(a,ERROR),a}},g.__dustBody=!!h.__dustBody,g):(void 0===h&&dust.log("Cannot find the value for reference [{"+b.join(".")+"}] in template ["+this.getTemplateName()+"]"),h)},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):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&&!a.__dustBody){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};for(var f in Chunk.prototype)dust._aliases[f]&&(Chunk.prototype[dust._aliases[f]]=Chunk.prototype[f]);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=/[&<>"']/,AMP=/&/g,LT=/</g,GT=/>/g,QUOT=/\"/g,SQUOT=/\'/g;dust.escapeHtml=function(a){return"string"==typeof a||a&&"function"==typeof a.toString?("string"!=typeof a&&(a=a.toString()),HCHARS.test(a)?a.replace(AMP,"&").replace(LT,"<").replace(GT,">").replace(QUOT,""").replace(SQUOT,"'"):a):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},dust.escapeJSON=function(a){return JSON?JSON.stringify(a).replace(LS,"\\u2028").replace(PS,"\\u2029").replace(LT,"\\u003c"):(dust.log("JSON is undefined. JSON stringify has not been used on ["+a+"]",WARN),a)},"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.core",function(){return dust}):"object"==typeof exports?module.exports=dust:root.dust=dust}(function(){return this}()),function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.parse",["dust.core"],function(dust){return b(dust).parse}):"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(uc).line}function d(){return f(uc).column}function e(a){throw h(a,null,uc)}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 vc!==b&&(vc>b&&(vc=0,wc={line:1,column:1,seenCR:!1}),c(wc,vc,b),vc=b),wc}function g(a){xc>tc||(tc>xc&&(xc=tc,yc=[]),yc.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=tc,b=[],c=k();c!==V;)b.push(c),c=k();return b!==V&&(uc=a,b=Y(b)),a=b}function k(){var a;return a=K(),a===V&&(a=L(),a===V&&(a=l(),a===V&&(a=s(),a===V&&(a=u(),a===V&&(a=r(),a===V&&(a=H())))))),a}function l(){var b,c,d,e,f,h,i,k;if(zc++,b=tc,c=m(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();d!==V?(e=O(),e!==V?(f=j(),f!==V?(h=q(),h!==V?(i=n(),i===V&&(i=_),i!==V?(uc=tc,k=aa(c,f,h,i),k=k?ba:$,k!==V?(uc=b,c=ca(c,f,h,i),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;if(b===V)if(b=tc,c=m(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();d!==V?(47===a.charCodeAt(tc)?(e=da,tc++):(e=V,0===zc&&g(ea)),e!==V?(f=O(),f!==V?(uc=b,c=fa(c),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(Z)),b}function m(){var b,c,d,e,f,h,i;if(b=tc,c=N(),c!==V)if(ga.test(a.charAt(tc))?(d=a.charAt(tc),tc++):(d=V,0===zc&&g(ha)),d!==V){for(e=[],f=S();f!==V;)e.push(f),f=S();e!==V?(f=v(),f!==V?(h=o(),h!==V?(i=p(),i!==V?(uc=b,c=ia(d,f,h,i),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;else tc=b,b=$;return b}function n(){var b,c,d,e,f,h,i;if(zc++,b=tc,c=N(),c!==V)if(47===a.charCodeAt(tc)?(d=da,tc++):(d=V,0===zc&&g(ea)),d!==V){for(e=[],f=S();f!==V;)e.push(f),f=S();if(e!==V)if(f=v(),f!==V){for(h=[],i=S();i!==V;)h.push(i),i=S();h!==V?(i=O(),i!==V?(uc=b,c=ka(f),b=c):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;else tc=b,b=$}else tc=b,b=$;else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(ja)),b}function o(){var b,c,d,e;return b=tc,c=tc,58===a.charCodeAt(tc)?(d=la,tc++):(d=V,0===zc&&g(ma)),d!==V?(e=v(),e!==V?(uc=c,d=na(e),c=d):(tc=c,c=$)):(tc=c,c=$),c===V&&(c=_),c!==V&&(uc=b,c=oa(c)),b=c}function p(){var b,c,d,e,f,h,i;if(zc++,b=tc,c=[],d=tc,e=[],f=S(),f!==V)for(;f!==V;)e.push(f),f=S();else e=$;for(e!==V?(f=C(),f!==V?(61===a.charCodeAt(tc)?(h=qa,tc++):(h=V,0===zc&&g(ra)),h!==V?(i=w(),i===V&&(i=v(),i===V&&(i=F())),i!==V?(uc=d,e=sa(f,i),d=e):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$);d!==V;){if(c.push(d),d=tc,e=[],f=S(),f!==V)for(;f!==V;)e.push(f),f=S();else e=$;e!==V?(f=C(),f!==V?(61===a.charCodeAt(tc)?(h=qa,tc++):(h=V,0===zc&&g(ra)),h!==V?(i=w(),i===V&&(i=v(),i===V&&(i=F())),i!==V?(uc=d,e=sa(f,i),d=e):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)}return c!==V&&(uc=b,c=ta(c)),b=c,zc--,b===V&&(c=V,0===zc&&g(pa)),b}function q(){var b,c,d,e,f,h,i,k;for(zc++,b=tc,c=[],d=tc,e=N(),e!==V?(58===a.charCodeAt(tc)?(f=la,tc++):(f=V,0===zc&&g(ma)),f!==V?(h=C(),h!==V?(i=O(),i!==V?(k=j(),k!==V?(uc=d,e=sa(h,k),d=e):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$);d!==V;)c.push(d),d=tc,e=N(),e!==V?(58===a.charCodeAt(tc)?(f=la,tc++):(f=V,0===zc&&g(ma)),f!==V?(h=C(),h!==V?(i=O(),i!==V?(k=j(),k!==V?(uc=d,e=sa(h,k),d=e):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$);return c!==V&&(uc=b,c=va(c)),b=c,zc--,b===V&&(c=V,0===zc&&g(ua)),b}function r(){var a,b,c,d,e;return zc++,a=tc,b=N(),b!==V?(c=v(),c!==V?(d=t(),d!==V?(e=O(),e!==V?(uc=a,b=xa(c,d),a=b):(tc=a,a=$)):(tc=a,a=$)):(tc=a,a=$)):(tc=a,a=$),zc--,a===V&&(b=V,0===zc&&g(wa)),a}function s(){var b,c,d,e,f,h,i,j,k,l;if(zc++,b=tc,c=N(),c!==V)if(62===a.charCodeAt(tc)?(d=za,tc++):(d=V,0===zc&&g(Aa)),d===V&&(43===a.charCodeAt(tc)?(d=Ba,tc++):(d=V,0===zc&&g(Ca))),d!==V){for(e=[],f=S();f!==V;)e.push(f),f=S();if(e!==V)if(f=tc,h=C(),h!==V&&(uc=f,h=Da(h)),f=h,f===V&&(f=F()),f!==V)if(h=o(),h!==V)if(i=p(),i!==V){for(j=[],k=S();k!==V;)j.push(k),k=S();j!==V?(47===a.charCodeAt(tc)?(k=da,tc++):(k=V,0===zc&&g(ea)),k!==V?(l=O(),l!==V?(uc=b,c=Ea(d,f,h,i),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;else tc=b,b=$;else tc=b,b=$;else tc=b,b=$}else tc=b,b=$;else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(ya)),b}function t(){var b,c,d,e,f;for(zc++,b=tc,c=[],d=tc,124===a.charCodeAt(tc)?(e=Ga,tc++):(e=V,0===zc&&g(Ha)),e!==V?(f=C(),f!==V?(uc=d,e=na(f),d=e):(tc=d,d=$)):(tc=d,d=$);d!==V;)c.push(d),d=tc,124===a.charCodeAt(tc)?(e=Ga,tc++):(e=V,0===zc&&g(Ha)),e!==V?(f=C(),f!==V?(uc=d,e=na(f),d=e):(tc=d,d=$)):(tc=d,d=$);return c!==V&&(uc=b,c=Ia(c)),b=c,zc--,b===V&&(c=V,0===zc&&g(Fa)),b}function u(){var b,c,d,e,f;return zc++,b=tc,c=N(),c!==V?(126===a.charCodeAt(tc)?(d=Ka,tc++):(d=V,0===zc&&g(La)),d!==V?(e=C(),e!==V?(f=O(),f!==V?(uc=b,c=Ma(e),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$),zc--,b===V&&(c=V,0===zc&&g(Ja)),b}function v(){var a,b;return zc++,a=tc,b=B(),b!==V&&(uc=a,b=Oa(b)),a=b,a===V&&(a=tc,b=C(),b!==V&&(uc=a,b=Pa(b)),a=b),zc--,a===V&&(b=V,0===zc&&g(Na)),a}function w(){var a,b;return zc++,a=tc,b=x(),b===V&&(b=A()),b!==V&&(uc=a,b=Ra(b)),a=b,zc--,a===V&&(b=V,0===zc&&g(Qa)),a}function x(){var b,c,d,e;return zc++,b=tc,c=A(),c!==V?(46===a.charCodeAt(tc)?(d=Ta,tc++):(d=V,0===zc&&g(Ua)),d!==V?(e=y(),e!==V?(uc=b,c=Va(c,e),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$),zc--,b===V&&(c=V,0===zc&&g(Sa)),b}function y(){var b,c,d;if(zc++,b=tc,c=[],Xa.test(a.charAt(tc))?(d=a.charAt(tc),tc++):(d=V,0===zc&&g(Ya)),d!==V)for(;d!==V;)c.push(d),Xa.test(a.charAt(tc))?(d=a.charAt(tc),tc++):(d=V,0===zc&&g(Ya));else c=$;return c!==V&&(uc=b,c=Za(c)),b=c,zc--,b===V&&(c=V,0===zc&&g(Wa)),b}function z(){var b,c,d;return zc++,b=tc,45===a.charCodeAt(tc)?(c=_a,tc++):(c=V,0===zc&&g(ab)),c!==V?(d=y(),d!==V?(uc=b,c=bb(c,d),b=c):(tc=b,b=$)):(tc=b,b=$),zc--,b===V&&(c=V,0===zc&&g($a)),b}function A(){var a,b;return zc++,a=z(),a===V&&(a=y()),zc--,a===V&&(b=V,0===zc&&g(cb)),a}function B(){var b,c,d,e;if(zc++,b=tc,c=C(),c===V&&(c=_),c!==V){if(d=[],e=E(),e===V&&(e=D()),e!==V)for(;e!==V;)d.push(e),e=E(),e===V&&(e=D());else d=$;d!==V?(uc=b,c=eb(c,d),b=c):(tc=b,b=$)}else tc=b,b=$;if(b===V)if(b=tc,46===a.charCodeAt(tc)?(c=Ta,tc++):(c=V,0===zc&&g(Ua)),c!==V){for(d=[],e=E(),e===V&&(e=D());e!==V;)d.push(e),e=E(),e===V&&(e=D());d!==V?(uc=b,c=fb(d),b=c):(tc=b,b=$)}else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(db)),b}function C(){var b,c,d,e;if(zc++,b=tc,hb.test(a.charAt(tc))?(c=a.charAt(tc),tc++):(c=V,0===zc&&g(ib)),c!==V){for(d=[],jb.test(a.charAt(tc))?(e=a.charAt(tc),tc++):(e=V,0===zc&&g(kb));e!==V;)d.push(e),jb.test(a.charAt(tc))?(e=a.charAt(tc),tc++):(e=V,0===zc&&g(kb));d!==V?(uc=b,c=lb(c,d),b=c):(tc=b,b=$)}else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(gb)),b}function D(){var b,c,d,e,f,h;if(zc++,b=tc,c=tc,d=P(),d!==V){if(e=tc,f=[],Xa.test(a.charAt(tc))?(h=a.charAt(tc),tc++):(h=V,0===zc&&g(Ya)),h!==V)for(;h!==V;)f.push(h),Xa.test(a.charAt(tc))?(h=a.charAt(tc),tc++):(h=V,0===zc&&g(Ya));else f=$;f!==V&&(uc=e,f=nb(f)),e=f,e===V&&(e=v()),e!==V?(f=Q(),f!==V?(uc=c,d=ob(e),c=d):(tc=c,c=$)):(tc=c,c=$)}else tc=c,c=$;return c!==V?(d=E(),d===V&&(d=_),d!==V?(uc=b,c=pb(c,d),b=c):(tc=b,b=$)):(tc=b,b=$),zc--,b===V&&(c=V,0===zc&&g(mb)),b}function E(){var b,c,d,e,f;if(zc++,b=tc,c=[],d=tc,46===a.charCodeAt(tc)?(e=Ta,tc++):(e=V,0===zc&&g(Ua)),e!==V?(f=C(),f!==V?(uc=d,e=rb(f),d=e):(tc=d,d=$)):(tc=d,d=$),d!==V)for(;d!==V;)c.push(d),d=tc,46===a.charCodeAt(tc)?(e=Ta,tc++):(e=V,0===zc&&g(Ua)),e!==V?(f=C(),f!==V?(uc=d,e=rb(f),d=e):(tc=d,d=$)):(tc=d,d=$);else c=$;return c!==V?(d=D(),d===V&&(d=_),d!==V?(uc=b,c=sb(c,d),b=c):(tc=b,b=$)):(tc=b,b=$),zc--,b===V&&(c=V,0===zc&&g(qb)),b}function F(){var b,c,d,e;if(zc++,b=tc,34===a.charCodeAt(tc)?(c=ub,tc++):(c=V,0===zc&&g(vb)),c!==V?(34===a.charCodeAt(tc)?(d=ub,tc++):(d=V,0===zc&&g(vb)),d!==V?(uc=b,c=wb(),b=c):(tc=b,b=$)):(tc=b,b=$),b===V&&(b=tc,34===a.charCodeAt(tc)?(c=ub,tc++):(c=V,0===zc&&g(vb)),c!==V?(d=I(),d!==V?(34===a.charCodeAt(tc)?(e=ub,tc++):(e=V,0===zc&&g(vb)),e!==V?(uc=b,c=xb(d),b=c):(tc=b,b=$)):(tc=b,b=$)):(tc=b,b=$),b===V))if(b=tc,34===a.charCodeAt(tc)?(c=ub,tc++):(c=V,0===zc&&g(vb)),c!==V){if(d=[],e=G(),e!==V)for(;e!==V;)d.push(e),e=G();else d=$;d!==V?(34===a.charCodeAt(tc)?(e=ub,tc++):(e=V,0===zc&&g(vb)),e!==V?(uc=b,c=yb(d),b=c):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(tb)),b}function G(){var a,b;return a=u(),a===V&&(a=r(),a===V&&(a=tc,b=I(),b!==V&&(uc=a,b=zb(b)),a=b)),a}function H(){var b,c,d,e,f,h,i,j;if(zc++,b=tc,c=R(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();d!==V?(uc=b,c=Bb(c,d),b=c):(tc=b,b=$)}else tc=b,b=$;if(b===V){if(b=tc,c=[],d=tc,e=tc,zc++,f=M(),zc--,f===V?e=ba:(tc=e,e=$),e!==V?(f=tc,zc++,h=K(),zc--,h===V?f=ba:(tc=f,f=$),f!==V?(h=tc,zc++,i=L(),zc--,i===V?h=ba:(tc=h,h=$),h!==V?(i=tc,zc++,j=R(),zc--,j===V?i=ba:(tc=i,i=$),i!==V?(a.length>tc?(j=a.charAt(tc),tc++):(j=V,0===zc&&g(Cb)),j!==V?(uc=d,e=Db(j),d=e):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$),d!==V)for(;d!==V;)c.push(d),d=tc,e=tc,zc++,f=M(),zc--,f===V?e=ba:(tc=e,e=$),e!==V?(f=tc,zc++,h=K(),zc--,h===V?f=ba:(tc=f,f=$),f!==V?(h=tc,zc++,i=L(),zc--,i===V?h=ba:(tc=h,h=$),h!==V?(i=tc,zc++,j=R(),zc--,j===V?i=ba:(tc=i,i=$),i!==V?(a.length>tc?(j=a.charAt(tc),tc++):(j=V,0===zc&&g(Cb)),j!==V?(uc=d,e=Db(j),d=e):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$)):(tc=d,d=$);else c=$;c!==V&&(uc=b,c=Eb(c)),b=c}return zc--,b===V&&(c=V,0===zc&&g(Ab)),b}function I(){var b,c,d,e,f;if(zc++,b=tc,c=[],d=tc,e=tc,zc++,f=M(),zc--,f===V?e=ba:(tc=e,e=$),e!==V?(f=J(),f===V&&(Gb.test(a.charAt(tc))?(f=a.charAt(tc),tc++):(f=V,0===zc&&g(Hb))),f!==V?(uc=d,e=Db(f),d=e):(tc=d,d=$)):(tc=d,d=$),d!==V)for(;d!==V;)c.push(d),d=tc,e=tc,zc++,f=M(),zc--,f===V?e=ba:(tc=e,e=$),e!==V?(f=J(),f===V&&(Gb.test(a.charAt(tc))?(f=a.charAt(tc),tc++):(f=V,0===zc&&g(Hb))),f!==V?(uc=d,e=Db(f),d=e):(tc=d,d=$)):(tc=d,d=$);else c=$;return c!==V&&(uc=b,c=Ib(c)),b=c,zc--,b===V&&(c=V,0===zc&&g(Fb)),b}function J(){var b,c;return b=tc,a.substr(tc,2)===Jb?(c=Jb,tc+=2):(c=V,0===zc&&g(Kb)),c!==V&&(uc=b,c=Lb()),b=c}function K(){var b,c,d,e,f,h;if(zc++,b=tc,a.substr(tc,2)===Nb?(c=Nb,tc+=2):(c=V,0===zc&&g(Ob)),c!==V){for(d=[],e=tc,f=tc,zc++,a.substr(tc,2)===Pb?(h=Pb,tc+=2):(h=V,0===zc&&g(Qb)),zc--,h===V?f=ba:(tc=f,f=$),f!==V?(a.length>tc?(h=a.charAt(tc),tc++):(h=V,0===zc&&g(Cb)),h!==V?(uc=e,f=Rb(h),e=f):(tc=e,e=$)):(tc=e,e=$);e!==V;)d.push(e),e=tc,f=tc,zc++,a.substr(tc,2)===Pb?(h=Pb,tc+=2):(h=V,0===zc&&g(Qb)),zc--,h===V?f=ba:(tc=f,f=$),f!==V?(a.length>tc?(h=a.charAt(tc),tc++):(h=V,0===zc&&g(Cb)),h!==V?(uc=e,f=Rb(h),e=f):(tc=e,e=$)):(tc=e,e=$);d!==V?(a.substr(tc,2)===Pb?(e=Pb,tc+=2):(e=V,0===zc&&g(Qb)),e!==V?(uc=b,c=Sb(d),b=c):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(Mb)),b}function L(){var b,c,d,e,f,h;if(zc++,b=tc,a.substr(tc,2)===Ub?(c=Ub,tc+=2):(c=V,0===zc&&g(Vb)),c!==V){for(d=[],e=tc,f=tc,zc++,a.substr(tc,2)===Wb?(h=Wb,tc+=2):(h=V,0===zc&&g(Xb)),zc--,h===V?f=ba:(tc=f,f=$),f!==V?(a.length>tc?(h=a.charAt(tc),tc++):(h=V,0===zc&&g(Cb)),h!==V?(uc=e,f=Db(h),e=f):(tc=e,e=$)):(tc=e,e=$);e!==V;)d.push(e),e=tc,f=tc,zc++,a.substr(tc,2)===Wb?(h=Wb,tc+=2):(h=V,0===zc&&g(Xb)),zc--,h===V?f=ba:(tc=f,f=$),f!==V?(a.length>tc?(h=a.charAt(tc),tc++):(h=V,0===zc&&g(Cb)),h!==V?(uc=e,f=Db(h),e=f):(tc=e,e=$)):(tc=e,e=$);d!==V?(a.substr(tc,2)===Wb?(e=Wb,tc+=2):(e=V,0===zc&&g(Xb)),e!==V?(uc=b,c=Yb(d),b=c):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$;return zc--,b===V&&(c=V,0===zc&&g(Tb)),b}function M(){var b,c,d,e,f,h,i,j,k,l;if(b=tc,c=N(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();if(d!==V)if(Zb.test(a.charAt(tc))?(e=a.charAt(tc),tc++):(e=V,0===zc&&g($b)),e!==V){for(f=[],h=S();h!==V;)f.push(h),h=S();if(f!==V){if(h=[],i=tc,j=tc,zc++,k=O(),zc--,k===V?j=ba:(tc=j,j=$),j!==V?(k=tc,zc++,l=R(),zc--,l===V?k=ba:(tc=k,k=$),k!==V?(a.length>tc?(l=a.charAt(tc),tc++):(l=V,0===zc&&g(Cb)),l!==V?(j=[j,k,l],i=j):(tc=i,i=$)):(tc=i,i=$)):(tc=i,i=$),i!==V)for(;i!==V;)h.push(i),i=tc,j=tc,zc++,k=O(),zc--,k===V?j=ba:(tc=j,j=$),j!==V?(k=tc,zc++,l=R(),zc--,l===V?k=ba:(tc=k,k=$),k!==V?(a.length>tc?(l=a.charAt(tc),tc++):(l=V,0===zc&&g(Cb)),l!==V?(j=[j,k,l],i=j):(tc=i,i=$)):(tc=i,i=$)):(tc=i,i=$);else h=$;if(h!==V){for(i=[],j=S();j!==V;)i.push(j),j=S();i!==V?(j=O(),j!==V?(c=[c,d,e,f,h,i,j],b=c):(tc=b,b=$)):(tc=b,b=$)}else tc=b,b=$}else tc=b,b=$}else tc=b,b=$;else tc=b,b=$}else tc=b,b=$;return b===V&&(b=r()),b}function N(){var b;return 123===a.charCodeAt(tc)?(b=_b,tc++):(b=V,0===zc&&g(ac)),b}function O(){var b;return 125===a.charCodeAt(tc)?(b=bc,tc++):(b=V,0===zc&&g(cc)),b}function P(){var b;return 91===a.charCodeAt(tc)?(b=dc,tc++):(b=V,0===zc&&g(ec)),b}function Q(){var b;return 93===a.charCodeAt(tc)?(b=fc,tc++):(b=V,0===zc&&g(gc)),b}function R(){var b;return 10===a.charCodeAt(tc)?(b=hc,tc++):(b=V,0===zc&&g(ic)),b===V&&(a.substr(tc,2)===jc?(b=jc,tc+=2):(b=V,0===zc&&g(kc)),b===V&&(13===a.charCodeAt(tc)?(b=lc,tc++):(b=V,0===zc&&g(mc)),b===V&&(8232===a.charCodeAt(tc)?(b=nc,tc++):(b=V,0===zc&&g(oc)),b===V&&(8233===a.charCodeAt(tc)?(b=pc,tc++):(b=V,0===zc&&g(qc)))))),b}function S(){var b;return rc.test(a.charAt(tc))?(b=a.charAt(tc),tc++):(b=V,0===zc&&g(sc)),b===V&&(b=R()),b}var T,U=arguments.length>1?arguments[1]:{},V={},W={start:i},X=i,Y=function(a){return["body"].concat(a).concat([["line",c()],["col",d()]])},Z={type:"other",description:"section"},$=V,_=null,aa=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},ba=void 0,ca=function(a,b,e){return e.push(["param",["literal","block"],b]),a.push(e),a.concat([["line",c()],["col",d()]])},da="/",ea={type:"literal",value:"/",description:'"/"'},fa=function(a){return a.push(["bodies"]),a.concat([["line",c()],["col",d()]])},ga=/^[#?\^<+@%]/,ha={type:"class",value:"[#?\\^<+@%]",description:"[#?\\^<+@%]"},ia=function(a,b,c,d){return[a,b,c,d]},ja={type:"other",description:"end tag"},ka=function(a){return a},la=":",ma={type:"literal",value:":",description:'":"'},na=function(a){return a},oa=function(a){return a?["context",a]:["context"]},pa={type:"other",description:"params"},qa="=",ra={type:"literal",value:"=",description:'"="'},sa=function(a,b){return["param",["literal",a],b]},ta=function(a){return["params"].concat(a)},ua={type:"other",description:"bodies"},va=function(a){return["bodies"].concat(a)},wa={type:"other",description:"reference"},xa=function(a,b){return["reference",a,b].concat([["line",c()],["col",d()]])},ya={type:"other",description:"partial"},za=">",Aa={type:"literal",value:">",description:'">"'},Ba="+",Ca={type:"literal",value:"+",description:'"+"'},Da=function(a){return["literal",a]},Ea=function(a,b,e,f){var g=">"===a?"partial":a;return[g,b,e,f].concat([["line",c()],["col",d()]])},Fa={type:"other",description:"filters"},Ga="|",Ha={type:"literal",value:"|",description:'"|"'},Ia=function(a){return["filters"].concat(a)},Ja={type:"other",description:"special"},Ka="~",La={type:"literal",value:"~",description:'"~"'},Ma=function(a){return["special",a].concat([["line",c()],["col",d()]])},Na={type:"other",description:"identifier"},Oa=function(a){var b=["path"].concat(a);return b.text=a[1].join(".").replace(/,line,\d+,col,\d+/g,""),b},Pa=function(a){var b=["key",a];return b.text=a,b},Qa={type:"other",description:"number"},Ra=function(a){return["literal",a]},Sa={type:"other",description:"float"},Ta=".",Ua={type:"literal",value:".",description:'"."'},Va=function(a,b){return parseFloat(a+"."+b)},Wa={type:"other",description:"unsigned_integer"},Xa=/^[0-9]/,Ya={type:"class",value:"[0-9]",description:"[0-9]"},Za=function(a){return parseInt(a.join(""),10)},$a={type:"other",description:"signed_integer"},_a="-",ab={type:"literal",value:"-",description:'"-"'},bb=function(a,b){return-1*b},cb={type:"other",description:"integer"},db={type:"other",description:"path"},eb=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()]])},fb=function(a){return a.length>0?[!0,a[0]].concat([["line",c()],["col",d()]]):[!0,[]].concat([["line",c()],["col",d()]])},gb={type:"other",description:"key"},hb=/^[a-zA-Z_$]/,ib={type:"class",value:"[a-zA-Z_$]",description:"[a-zA-Z_$]"},jb=/^[0-9a-zA-Z_$\-]/,kb={type:"class",value:"[0-9a-zA-Z_$\\-]",description:"[0-9a-zA-Z_$\\-]"},lb=function(a,b){return a+b.join("")},mb={type:"other",description:"array"},nb=function(a){return a.join("")},ob=function(a){return a},pb=function(a,b){return b?b.unshift(a):b=[a],b},qb={type:"other",description:"array_part"},rb=function(a){return a},sb=function(a,b){return b?a.concat(b):a},tb={type:"other",description:"inline"},ub='"',vb={type:"literal",value:'"',description:'"\\""'},wb=function(){return["literal",""].concat([["line",c()],["col",d()]])},xb=function(a){return["literal",a].concat([["line",c()],["col",d()]])},yb=function(a){return["body"].concat(a).concat([["line",c()],["col",d()]])},zb=function(a){return["buffer",a]},Ab={type:"other",description:"buffer"},Bb=function(a,b){return["format",a,b.join("")].concat([["line",c()],["col",d()]])},Cb={type:"any",description:"any character"},Db=function(a){return a},Eb=function(a){return["buffer",a.join("")].concat([["line",c()],["col",d()]])},Fb={type:"other",description:"literal"},Gb=/^[^"]/,Hb={type:"class",value:'[^"]',description:'[^"]'},Ib=function(a){return a.join("")},Jb='\\"',Kb={type:"literal",value:'\\"',description:'"\\\\\\""'},Lb=function(){return'"'},Mb={type:"other",description:"raw"},Nb="{`",Ob={type:"literal",value:"{`",description:'"{`"'},Pb="`}",Qb={type:"literal",value:"`}",description:'"`}"'},Rb=function(a){return a},Sb=function(a){return["raw",a.join("")].concat([["line",c()],["col",d()]])},Tb={type:"other",description:"comment"},Ub="{!",Vb={type:"literal",value:"{!",description:'"{!"'},Wb="!}",Xb={type:"literal",value:"!}",description:'"!}"'},Yb=function(a){return["comment",a.join("")].concat([["line",c()],["col",d()]])},Zb=/^[#?\^><+%:@\/~%]/,$b={type:"class",value:"[#?\\^><+%:@\\/~%]",description:"[#?\\^><+%:@\\/~%]"},_b="{",ac={type:"literal",value:"{",description:'"{"'},bc="}",cc={type:"literal",value:"}",description:'"}"'},dc="[",ec={type:"literal",value:"[",description:'"["'},fc="]",gc={type:"literal",value:"]",description:'"]"'},hc="\n",ic={type:"literal",value:"\n",description:'"\\n"'},jc="\r\n",kc={type:"literal",value:"\r\n",description:'"\\r\\n"'},lc="\r",mc={type:"literal",value:"\r",description:'"\\r"'},nc="\u2028",oc={type:"literal",value:"\u2028",description:'"\\u2028"'},pc="\u2029",qc={type:"literal",value:"\u2029",description:'"\\u2029"'},rc=/^[\t\x0B\f \xA0\uFEFF]/,sc={type:"class",value:"[\\t\\x0B\\f \\xA0\\uFEFF]",description:"[\\t\\x0B\\f \\xA0\\uFEFF]"},tc=0,uc=0,vc=0,wc={line:1,column:1,seenCR:!1},xc=0,yc=[],zc=0;if("startRule"in U){if(!(U.startRule in W))throw new Error("Can't start parsing from rule \""+U.startRule+'".');X=W[U.startRule]}if(T=X(),T!==V&&tc===a.length)return T;throw T!==V&&tc<a.length&&g({type:"end",description:"end of input"}),h(null,yc,xc)}return a(b,Error),{SyntaxError:b,parse:c}}();return dust.parse=a.parse,a}),function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.compile",["dust.core","dust.parse"],function(dust,a){return b(a,dust).compile}):"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 o.filterNode(b,a)}function c(a,b){var c,d,e,f=[b[0]];for(c=1,d=b.length;d>c;c++)e=o.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=o.filterNode(a,b[d]),f&&("buffer"===f[0]||"format"===f[0]?c?(c[0]="buffer"===f[0]?"buffer":c[0],c[1]+=f.slice(1,-2).join("")):(c=f,g.push(f)):(c=null,g.push(f)));return g}function e(a,b){return["buffer",q[b[1]],b[2],b[3]]}function f(a,b){return b}function g(){}function h(a,b){return dust.config.whitespace?(b.splice(1,2,b.slice(1,-2).join("")),b):null}function i(a,b){var c={name:b,bodies:[],blocks:{},index:0,auto:"h"},d=dust.escapeJs(b),e="function(dust){dust.register("+(b?'"'+d+'"':"null")+","+o.compileNode(c,a)+");"+j(c)+k(c)+"return body_0;}";return dust.config.amd?'define("'+d+'",["dust.core"],'+e+");":"("+e+")(dust);"}function j(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 k(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]+";}body_"+b+".__dustBody=!0;";return d.join("")}function l(a,b){var c,d,e="";for(c=1,d=b.length;d>c;c++)e+=o.compileNode(a,b[c]);return e}function m(a,b,c){return"."+(dust._aliases[c]||c)+"("+o.compileNode(a,b[1])+","+o.compileNode(a,b[2])+","+o.compileNode(a,b[4])+","+o.compileNode(a,b[3])+")"}function n(a){return a.replace(r,"\\\\").replace(s,'\\"').replace(t,"\\f").replace(u,"\\n").replace(v,"\\r").replace(w,"\\t")}var o={},p=dust.isArray;o.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 i(e,d)}catch(f){if(!f.line||!f.column)throw f;throw new SyntaxError(f.message+" At line : "+f.line+", column : "+f.column)}},o.filterNode=function(a,b){return o.optimizers[b[0]](a,b)},o.optimizers={body:d,buffer:f,special:e,format:h,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},o.pragmas={esc:function(a,b,c){var d,e=a.auto;return b||(b="h"),a.auto="s"===b?"":b,d=l(a,c.block),a.auto=e,d}};var q={s:" ",n:"\n",r:"\r",lb:"{",rb:"}"};o.compileNode=function(a,b){return o.nodes[b[0]](a,b)},o.nodes={body:function(a,b){var c=a.index++,d="body_"+c;return a.bodies[c]=l(a,b),d},buffer:function(a,b){return".w("+x(b[1])+")"},format:function(a,b){return".w("+x(b[1])+")"},reference:function(a,b){return".f("+o.compileNode(a,b[1])+",ctx,"+o.compileNode(a,b[2])+")"},"#":function(a,b){return m(a,b,"section")},"?":function(a,b){return m(a,b,"exists")},"^":function(a,b){return m(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]=o.compileNode(a,f[2]),""}return""},"+":function(a,b){return"undefined"==typeof b[1].text&&"undefined"==typeof b[4]?".block(ctx.getBlock("+o.compileNode(a,b[1])+",chk, ctx),"+o.compileNode(a,b[2])+", {},"+o.compileNode(a,b[3])+")":".block(ctx.getBlock("+x(b[1].text)+"),"+o.compileNode(a,b[2])+","+o.compileNode(a,b[4])+","+o.compileNode(a,b[3])+")"},"@":function(a,b){return".h("+x(b[1].text)+","+o.compileNode(a,b[2])+","+o.compileNode(a,b[4])+","+o.compileNode(a,b[3])+")"},"%":function(a,b){var c,d,e,f,g,h,i,j,k,l=b[1][1];if(!o.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,o.pragmas[l](a,g,d,f)},partial:function(a,b){return".p("+o.compileNode(a,b[1])+","+o.compileNode(a,b[2])+","+o.compileNode(a,b[3])+")"},context:function(a,b){return b[1]?"ctx.rebase("+o.compileNode(a,b[1])+")":"ctx"},params:function(a,b){for(var c=[],d=1,e=b.length;e>d;d++)c.push(o.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(o.compileNode(a,b[d]));return"{"+c.join(",")+"}"},param:function(a,b){return o.compileNode(a,b[1])+":"+o.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(p(d[f])?o.compileNode(a,d[f]):'"'+d[f]+'"');return"ctx.getPath("+c+", ["+e.join(",")+"])"},literal:function(a,b){return x(b[1])},raw:function(a,b){return".w("+x(b[1])+")"}};var r=/\\/g,s=/"/g,t=/\f/g,u=/\n/g,v=/\r/g,w=/\t/g,x="undefined"==typeof JSON?function(a){return'"'+n(a)+'"'}:JSON.stringify;return dust.compile=o.compile,dust.filterNode=o.filterNode,dust.optimizers=o.optimizers,dust.pragmas=o.pragmas,dust.compileNode=o.compileNode,dust.nodes=o.nodes,o}),"function"==typeof define&&define.amd&&define.amd.dust===!0&&define(["require","dust.core","dust.compile"],function(require,dust){return dust.onLoad=function(a,b){require([a],function(){b()})},dust}); | ||
!function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.core",[],b):"object"==typeof exports?module.exports=b():a.dust=b()}(this,function(){function Context(a,b,c,d){this.stack=a,this.global=b,this.blocks=c,this.templateName=d}function getWithResolvedData(a,b,c){return function(d){return a.push(d)._get(b,c)}}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={version:"2.6.2"},NONE="NONE",ERROR="ERROR",WARN="WARN",INFO="INFO",DEBUG="DEBUG",EMPTY_FUNC=function(){};dust.config={whitespace:!1,amd:!1},dust._aliases={write:"w",end:"e",map:"m",render:"r",reference:"f",section:"s",exists:"x",notexists:"nx",block:"b",partial:"p",helper:"h"},function(){var a,b,c={DEBUG:0,INFO:1,WARN:2,ERROR:3,NONE:4};"undefined"!=typeof console&&console.log?(a=console.log,b="function"==typeof a?function(){a.apply(console,arguments)}:function(){a(Array.prototype.slice.apply(arguments).join(" "))}):b=EMPTY_FUNC,dust.log=function(a,d){d=d||INFO,c[d]>=c[dust.debugLevel]&&b("[DUST:"+d+"]",a)},dust.debugLevel=NONE,"undefined"!=typeof process&&process.env&&/\bdust\b/.test(process.env.DEBUG)&&(dust.debugLevel=DEBUG)}(),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+"` could not be loaded"),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.nextTick=function(){return function(a){setTimeout(a,0)}}(),dust.isEmpty=function(a){return 0===a?!1:dust.isArray(a)&&!a.length?!0:!a},dust.isEmptyObject=function(a){var b;if(null===a)return!1;if(void 0===a)return!1;if(a.length>0)return!1;for(b in a)if(Object.prototype.hasOwnProperty.call(a,b))return!1;return!0},dust.isThenable=function(a){return a&&"object"==typeof a&&"function"==typeof a.then},dust.filter=function(a,b,c){var d,e,f;if(c)for(d=0,e=c.length;e>d;d++)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 dust.escapeJSON(a)},jp:function(a){return JSON?JSON.parse(a):(dust.log("JSON is undefined; could not parse `"+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,h=this.stack||{},i=1;if(d=b[0],e=b.length,a&&0===e)f=h,h=h.head;else{if(a)h&&(h=h.head?h.head[d]:void 0);else{for(;h&&(!h.isObject||(f=h.head,c=h.head[d],void 0===c));)h=h.tail;h=void 0!==c?c:this.global?this.global[d]:void 0}for(;h&&e>i;){if(dust.isThenable(h))return h.then(getWithResolvedData(this,a,b.slice(i)));f=h,h=h[b[i]],i++}}return"function"==typeof h?(g=function(){try{return h.apply(f,arguments)}catch(a){throw dust.log(a,ERROR),a}},g.__dustBody=!!h.__dustBody,g):(void 0===h&&dust.log("Cannot find reference `{"+b.join(".")+"}` in template `"+this.getTemplateName()+"`",INFO),h)},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.pop=function(){var a=this.current();return this.stack=this.stack&&this.stack.tail,a},Context.prototype.rebase=function(a){return new Context(new Stack(a),this.global,this.blocks,this.getTemplateName())},Context.prototype.clone=function(){var a=this.rebase();return a.stack=this.stack,a},Context.prototype.current=function(){return this.stack&&this.stack.head},Context.prototype.getBlock=function(a){var b,c,d;if("function"==typeof a&&(a=a(new Chunk,this).data.join("")),b=this.blocks,!b)return dust.log("No blocks for context `"+a+"` in template `"+this.getTemplateName()+"`",DEBUG),!1;for(c=b.length;c--;)if(d=b[c][a])return d;return dust.log("Malformed template `"+this.getTemplateName()+"` was missing one or more blocks."),!1},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.resolve=function(a){var b;return"function"!=typeof a?a:(b=(new Chunk).render(a,this),a.__dustBody?b.data.join(""):b)},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("Rendering failed with error `"+a.error+"`",ERROR),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("Streaming failed with error `"+a.error+"`",ERROR),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){var c,d,e=this.events||{},f=e[a]||[];if(!f.length)return void dust.log("Stream broadcasting, but no listeners for `"+a+"`",DEBUG);for(f=f.slice(0),c=0,d=f.length;d>c;c++)f[c](b)},Stream.prototype.on=function(a,b){var c=this.events=this.events||{},d=c[a]=c[a]||[];return"function"!=typeof b?dust.log("No callback function provided for `"+a+"` event listener",WARN):d.push(b),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{a.end()}catch(b){dust.log(b,ERROR)}}).on("error",function(b){a.error(b)})},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.isThenable(a)?this.await(a,b):dust.isEmpty(a)?this:this.write(dust.filter(a,c,d))},Chunk.prototype.section=function(a,b,c,d){var e,f,g=c.block,h=c["else"],i=this;if("function"==typeof a&&!a.__dustBody){try{a=a.apply(b.current(),[this,b,c,d])}catch(j){return dust.log(j,ERROR),this.setError(j)}if(a instanceof Chunk)return a}if(dust.isEmptyObject(d)||(b=b.push(d)),dust.isArray(a)){if(g){if(f=a.length,f>0){for(b.stack.head&&(b.stack.head.$len=f),e=0;f>e;e++)b.stack.head&&(b.stack.head.$idx=e),i=g(i,b.push(a[e],e,f));return b.stack.head&&(b.stack.head.$idx=void 0,b.stack.head.$len=void 0),i}if(h)return h(this,b)}}else{if(dust.isThenable(a))return this.await(a,b,c);if(a===!0){if(g)return g(this,b)}else if(a||0===a){if(g)return g(this,b.push(a))}else if(h)return h(this,b)}return dust.log("Section without corresponding key in template `"+b.getTemplateName()+"`",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);dust.log("No block for exists check in template `"+b.getTemplateName()+"`",DEBUG)}return 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);dust.log("No block for not-exists check in template `"+b.getTemplateName()+"`",DEBUG)}else if(e)return e(this,b);return this},Chunk.prototype.block=function(a,b,c){var d=a||c.block;return d?d(this,b):this},Chunk.prototype.partial=function(a,b,c){var d;return dust.isEmptyObject(c)||(b=b.clone(),d=b.pop(),b=b.push(c).push(d)),a.__dustBody?this.capture(a,b,function(a,c){b.templateName=a,dust.load(a,c,b).end()}):(b.templateName=a,dust.load(a,this,b))},Chunk.prototype.helper=function(a,b,c,d){var e,f=this;if(!dust.helpers[a])return dust.log("Helper `"+a+"` does not exist",WARN),f;try{return e=dust.helpers[a](f,b,c,d),dust.isThenable(e)?this.await(e,b,c):e}catch(g){return dust.log("Error in helper `"+a+"`: "+g.message,ERROR),f.setError(g)}},Chunk.prototype.await=function(a,b,c){var d=c&&c.block,e=c&&c.error;return this.map(function(c){a.then(function(a){d?c.render(d,b.push(a)).end():c.end(a)},function(a){e?c.render(e,b.push(a)).end():(dust.log("Unhandled promise rejection in `"+b.getTemplateName()+"`"),c.end())})})},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};for(var f in Chunk.prototype)dust._aliases[f]&&(Chunk.prototype[dust._aliases[f]]=Chunk.prototype[f]);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=/[&<>"']/,AMP=/&/g,LT=/</g,GT=/>/g,QUOT=/\"/g,SQUOT=/\'/g;dust.escapeHtml=function(a){return"string"==typeof a||a&&"function"==typeof a.toString?("string"!=typeof a&&(a=a.toString()),HCHARS.test(a)?a.replace(AMP,"&").replace(LT,"<").replace(GT,">").replace(QUOT,""").replace(SQUOT,"'"):a):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;return 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},dust.escapeJSON=function(a){return JSON?JSON.stringify(a).replace(LS,"\\u2028").replace(PS,"\\u2029").replace(LT,"\\u003c"):(dust.log("JSON is undefined; could not escape `"+a+"`",WARN),a)},dust}),function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.parse",["dust.core"],function(dust){return b(dust).parse}):"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(ud).line}function d(){return f(ud).column}function e(a){throw h(a,null,ud)}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 vd!==b&&(vd>b&&(vd=0,wd={line:1,column:1,seenCR:!1}),c(wd,vd,b),vd=b),wd}function g(a){xd>td||(td>xd&&(xd=td,yd=[]),yd.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=td,b=[],c=k();c!==V;)b.push(c),c=k();return b!==V&&(ud=a,b=Y(b)),a=b}function k(){var a;return a=K(),a===V&&(a=L(),a===V&&(a=l(),a===V&&(a=s(),a===V&&(a=u(),a===V&&(a=r(),a===V&&(a=H())))))),a}function l(){var b,c,d,e,f,h,i,k;if(zd++,b=td,c=m(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();d!==V?(e=O(),e!==V?(f=j(),f!==V?(h=q(),h!==V?(i=n(),i===V&&(i=_),i!==V?(ud=td,k=ab(c,f,h,i),k=k?bb:$,k!==V?(ud=b,c=cb(c,f,h,i),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;if(b===V)if(b=td,c=m(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();d!==V?(47===a.charCodeAt(td)?(e=db,td++):(e=V,0===zd&&g(eb)),e!==V?(f=O(),f!==V?(ud=b,c=fb(c),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(Z)),b}function m(){var b,c,d,e,f,h,i;if(b=td,c=N(),c!==V)if(gb.test(a.charAt(td))?(d=a.charAt(td),td++):(d=V,0===zd&&g(hb)),d!==V){for(e=[],f=S();f!==V;)e.push(f),f=S();e!==V?(f=v(),f!==V?(h=o(),h!==V?(i=p(),i!==V?(ud=b,c=ib(d,f,h,i),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;else td=b,b=$;return b}function n(){var b,c,d,e,f,h,i;if(zd++,b=td,c=N(),c!==V)if(47===a.charCodeAt(td)?(d=db,td++):(d=V,0===zd&&g(eb)),d!==V){for(e=[],f=S();f!==V;)e.push(f),f=S();if(e!==V)if(f=v(),f!==V){for(h=[],i=S();i!==V;)h.push(i),i=S();h!==V?(i=O(),i!==V?(ud=b,c=kb(f),b=c):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;else td=b,b=$}else td=b,b=$;else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(jb)),b}function o(){var b,c,d,e;return b=td,c=td,58===a.charCodeAt(td)?(d=lb,td++):(d=V,0===zd&&g(mb)),d!==V?(e=v(),e!==V?(ud=c,d=nb(e),c=d):(td=c,c=$)):(td=c,c=$),c===V&&(c=_),c!==V&&(ud=b,c=ob(c)),b=c}function p(){var b,c,d,e,f,h,i;if(zd++,b=td,c=[],d=td,e=[],f=S(),f!==V)for(;f!==V;)e.push(f),f=S();else e=$;for(e!==V?(f=C(),f!==V?(61===a.charCodeAt(td)?(h=qb,td++):(h=V,0===zd&&g(rb)),h!==V?(i=w(),i===V&&(i=v(),i===V&&(i=F())),i!==V?(ud=d,e=sb(f,i),d=e):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$);d!==V;){if(c.push(d),d=td,e=[],f=S(),f!==V)for(;f!==V;)e.push(f),f=S();else e=$;e!==V?(f=C(),f!==V?(61===a.charCodeAt(td)?(h=qb,td++):(h=V,0===zd&&g(rb)),h!==V?(i=w(),i===V&&(i=v(),i===V&&(i=F())),i!==V?(ud=d,e=sb(f,i),d=e):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)}return c!==V&&(ud=b,c=tb(c)),b=c,zd--,b===V&&(c=V,0===zd&&g(pb)),b}function q(){var b,c,d,e,f,h,i,k;for(zd++,b=td,c=[],d=td,e=N(),e!==V?(58===a.charCodeAt(td)?(f=lb,td++):(f=V,0===zd&&g(mb)),f!==V?(h=C(),h!==V?(i=O(),i!==V?(k=j(),k!==V?(ud=d,e=sb(h,k),d=e):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$);d!==V;)c.push(d),d=td,e=N(),e!==V?(58===a.charCodeAt(td)?(f=lb,td++):(f=V,0===zd&&g(mb)),f!==V?(h=C(),h!==V?(i=O(),i!==V?(k=j(),k!==V?(ud=d,e=sb(h,k),d=e):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$);return c!==V&&(ud=b,c=vb(c)),b=c,zd--,b===V&&(c=V,0===zd&&g(ub)),b}function r(){var a,b,c,d,e;return zd++,a=td,b=N(),b!==V?(c=v(),c!==V?(d=t(),d!==V?(e=O(),e!==V?(ud=a,b=xb(c,d),a=b):(td=a,a=$)):(td=a,a=$)):(td=a,a=$)):(td=a,a=$),zd--,a===V&&(b=V,0===zd&&g(wb)),a}function s(){var b,c,d,e,f,h,i,j,k,l;if(zd++,b=td,c=N(),c!==V)if(62===a.charCodeAt(td)?(d=zb,td++):(d=V,0===zd&&g(Ab)),d===V&&(43===a.charCodeAt(td)?(d=Bb,td++):(d=V,0===zd&&g(Cb))),d!==V){for(e=[],f=S();f!==V;)e.push(f),f=S();if(e!==V)if(f=td,h=C(),h!==V&&(ud=f,h=Db(h)),f=h,f===V&&(f=F()),f!==V)if(h=o(),h!==V)if(i=p(),i!==V){for(j=[],k=S();k!==V;)j.push(k),k=S();j!==V?(47===a.charCodeAt(td)?(k=db,td++):(k=V,0===zd&&g(eb)),k!==V?(l=O(),l!==V?(ud=b,c=Eb(d,f,h,i),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;else td=b,b=$;else td=b,b=$;else td=b,b=$}else td=b,b=$;else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(yb)),b}function t(){var b,c,d,e,f;for(zd++,b=td,c=[],d=td,124===a.charCodeAt(td)?(e=Gb,td++):(e=V,0===zd&&g(Hb)),e!==V?(f=C(),f!==V?(ud=d,e=nb(f),d=e):(td=d,d=$)):(td=d,d=$);d!==V;)c.push(d),d=td,124===a.charCodeAt(td)?(e=Gb,td++):(e=V,0===zd&&g(Hb)),e!==V?(f=C(),f!==V?(ud=d,e=nb(f),d=e):(td=d,d=$)):(td=d,d=$);return c!==V&&(ud=b,c=Ib(c)),b=c,zd--,b===V&&(c=V,0===zd&&g(Fb)),b}function u(){var b,c,d,e,f;return zd++,b=td,c=N(),c!==V?(126===a.charCodeAt(td)?(d=Kb,td++):(d=V,0===zd&&g(Lb)),d!==V?(e=C(),e!==V?(f=O(),f!==V?(ud=b,c=Mb(e),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$)):(td=b,b=$),zd--,b===V&&(c=V,0===zd&&g(Jb)),b}function v(){var a,b;return zd++,a=td,b=B(),b!==V&&(ud=a,b=Ob(b)),a=b,a===V&&(a=td,b=C(),b!==V&&(ud=a,b=Pb(b)),a=b),zd--,a===V&&(b=V,0===zd&&g(Nb)),a}function w(){var a,b;return zd++,a=td,b=x(),b===V&&(b=A()),b!==V&&(ud=a,b=Rb(b)),a=b,zd--,a===V&&(b=V,0===zd&&g(Qb)),a}function x(){var b,c,d,e;return zd++,b=td,c=A(),c!==V?(46===a.charCodeAt(td)?(d=Tb,td++):(d=V,0===zd&&g(Ub)),d!==V?(e=y(),e!==V?(ud=b,c=Vb(c,e),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$),zd--,b===V&&(c=V,0===zd&&g(Sb)),b}function y(){var b,c,d;if(zd++,b=td,c=[],Xb.test(a.charAt(td))?(d=a.charAt(td),td++):(d=V,0===zd&&g(Yb)),d!==V)for(;d!==V;)c.push(d),Xb.test(a.charAt(td))?(d=a.charAt(td),td++):(d=V,0===zd&&g(Yb));else c=$;return c!==V&&(ud=b,c=Zb(c)),b=c,zd--,b===V&&(c=V,0===zd&&g(Wb)),b}function z(){var b,c,d;return zd++,b=td,45===a.charCodeAt(td)?(c=_b,td++):(c=V,0===zd&&g(ac)),c!==V?(d=y(),d!==V?(ud=b,c=bc(c,d),b=c):(td=b,b=$)):(td=b,b=$),zd--,b===V&&(c=V,0===zd&&g($b)),b}function A(){var a,b;return zd++,a=z(),a===V&&(a=y()),zd--,a===V&&(b=V,0===zd&&g(cc)),a}function B(){var b,c,d,e;if(zd++,b=td,c=C(),c===V&&(c=_),c!==V){if(d=[],e=E(),e===V&&(e=D()),e!==V)for(;e!==V;)d.push(e),e=E(),e===V&&(e=D());else d=$;d!==V?(ud=b,c=ec(c,d),b=c):(td=b,b=$)}else td=b,b=$;if(b===V)if(b=td,46===a.charCodeAt(td)?(c=Tb,td++):(c=V,0===zd&&g(Ub)),c!==V){for(d=[],e=E(),e===V&&(e=D());e!==V;)d.push(e),e=E(),e===V&&(e=D());d!==V?(ud=b,c=fc(d),b=c):(td=b,b=$)}else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(dc)),b}function C(){var b,c,d,e;if(zd++,b=td,hc.test(a.charAt(td))?(c=a.charAt(td),td++):(c=V,0===zd&&g(ic)),c!==V){for(d=[],jc.test(a.charAt(td))?(e=a.charAt(td),td++):(e=V,0===zd&&g(kc));e!==V;)d.push(e),jc.test(a.charAt(td))?(e=a.charAt(td),td++):(e=V,0===zd&&g(kc));d!==V?(ud=b,c=lc(c,d),b=c):(td=b,b=$)}else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(gc)),b}function D(){var b,c,d,e,f,h;if(zd++,b=td,c=td,d=P(),d!==V){if(e=td,f=[],Xb.test(a.charAt(td))?(h=a.charAt(td),td++):(h=V,0===zd&&g(Yb)),h!==V)for(;h!==V;)f.push(h),Xb.test(a.charAt(td))?(h=a.charAt(td),td++):(h=V,0===zd&&g(Yb));else f=$;f!==V&&(ud=e,f=nc(f)),e=f,e===V&&(e=v()),e!==V?(f=Q(),f!==V?(ud=c,d=oc(e),c=d):(td=c,c=$)):(td=c,c=$)}else td=c,c=$;return c!==V?(d=E(),d===V&&(d=_),d!==V?(ud=b,c=pc(c,d),b=c):(td=b,b=$)):(td=b,b=$),zd--,b===V&&(c=V,0===zd&&g(mc)),b}function E(){var b,c,d,e,f;if(zd++,b=td,c=[],d=td,46===a.charCodeAt(td)?(e=Tb,td++):(e=V,0===zd&&g(Ub)),e!==V?(f=C(),f!==V?(ud=d,e=rc(f),d=e):(td=d,d=$)):(td=d,d=$),d!==V)for(;d!==V;)c.push(d),d=td,46===a.charCodeAt(td)?(e=Tb,td++):(e=V,0===zd&&g(Ub)),e!==V?(f=C(),f!==V?(ud=d,e=rc(f),d=e):(td=d,d=$)):(td=d,d=$);else c=$;return c!==V?(d=D(),d===V&&(d=_),d!==V?(ud=b,c=sc(c,d),b=c):(td=b,b=$)):(td=b,b=$),zd--,b===V&&(c=V,0===zd&&g(qc)),b}function F(){var b,c,d,e;if(zd++,b=td,34===a.charCodeAt(td)?(c=uc,td++):(c=V,0===zd&&g(vc)),c!==V?(34===a.charCodeAt(td)?(d=uc,td++):(d=V,0===zd&&g(vc)),d!==V?(ud=b,c=wc(),b=c):(td=b,b=$)):(td=b,b=$),b===V&&(b=td,34===a.charCodeAt(td)?(c=uc,td++):(c=V,0===zd&&g(vc)),c!==V?(d=I(),d!==V?(34===a.charCodeAt(td)?(e=uc,td++):(e=V,0===zd&&g(vc)),e!==V?(ud=b,c=xc(d),b=c):(td=b,b=$)):(td=b,b=$)):(td=b,b=$),b===V))if(b=td,34===a.charCodeAt(td)?(c=uc,td++):(c=V,0===zd&&g(vc)),c!==V){if(d=[],e=G(),e!==V)for(;e!==V;)d.push(e),e=G();else d=$;d!==V?(34===a.charCodeAt(td)?(e=uc,td++):(e=V,0===zd&&g(vc)),e!==V?(ud=b,c=yc(d),b=c):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(tc)),b}function G(){var a,b;return a=u(),a===V&&(a=r(),a===V&&(a=td,b=I(),b!==V&&(ud=a,b=zc(b)),a=b)),a}function H(){var b,c,d,e,f,h,i,j;if(zd++,b=td,c=R(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();d!==V?(ud=b,c=Bc(c,d),b=c):(td=b,b=$)}else td=b,b=$;if(b===V){if(b=td,c=[],d=td,e=td,zd++,f=M(),zd--,f===V?e=bb:(td=e,e=$),e!==V?(f=td,zd++,h=K(),zd--,h===V?f=bb:(td=f,f=$),f!==V?(h=td,zd++,i=L(),zd--,i===V?h=bb:(td=h,h=$),h!==V?(i=td,zd++,j=R(),zd--,j===V?i=bb:(td=i,i=$),i!==V?(a.length>td?(j=a.charAt(td),td++):(j=V,0===zd&&g(Cc)),j!==V?(ud=d,e=Dc(j),d=e):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$),d!==V)for(;d!==V;)c.push(d),d=td,e=td,zd++,f=M(),zd--,f===V?e=bb:(td=e,e=$),e!==V?(f=td,zd++,h=K(),zd--,h===V?f=bb:(td=f,f=$),f!==V?(h=td,zd++,i=L(),zd--,i===V?h=bb:(td=h,h=$),h!==V?(i=td,zd++,j=R(),zd--,j===V?i=bb:(td=i,i=$),i!==V?(a.length>td?(j=a.charAt(td),td++):(j=V,0===zd&&g(Cc)),j!==V?(ud=d,e=Dc(j),d=e):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$)):(td=d,d=$);else c=$;c!==V&&(ud=b,c=Ec(c)),b=c}return zd--,b===V&&(c=V,0===zd&&g(Ac)),b}function I(){var b,c,d,e,f;if(zd++,b=td,c=[],d=td,e=td,zd++,f=M(),zd--,f===V?e=bb:(td=e,e=$),e!==V?(f=J(),f===V&&(Gc.test(a.charAt(td))?(f=a.charAt(td),td++):(f=V,0===zd&&g(Hc))),f!==V?(ud=d,e=Dc(f),d=e):(td=d,d=$)):(td=d,d=$),d!==V)for(;d!==V;)c.push(d),d=td,e=td,zd++,f=M(),zd--,f===V?e=bb:(td=e,e=$),e!==V?(f=J(),f===V&&(Gc.test(a.charAt(td))?(f=a.charAt(td),td++):(f=V,0===zd&&g(Hc))),f!==V?(ud=d,e=Dc(f),d=e):(td=d,d=$)):(td=d,d=$);else c=$;return c!==V&&(ud=b,c=Ic(c)),b=c,zd--,b===V&&(c=V,0===zd&&g(Fc)),b}function J(){var b,c;return b=td,a.substr(td,2)===Jc?(c=Jc,td+=2):(c=V,0===zd&&g(Kc)),c!==V&&(ud=b,c=Lc()),b=c}function K(){var b,c,d,e,f,h;if(zd++,b=td,a.substr(td,2)===Nc?(c=Nc,td+=2):(c=V,0===zd&&g(Oc)),c!==V){for(d=[],e=td,f=td,zd++,a.substr(td,2)===Pc?(h=Pc,td+=2):(h=V,0===zd&&g(Qc)),zd--,h===V?f=bb:(td=f,f=$),f!==V?(a.length>td?(h=a.charAt(td),td++):(h=V,0===zd&&g(Cc)),h!==V?(ud=e,f=Rc(h),e=f):(td=e,e=$)):(td=e,e=$);e!==V;)d.push(e),e=td,f=td,zd++,a.substr(td,2)===Pc?(h=Pc,td+=2):(h=V,0===zd&&g(Qc)),zd--,h===V?f=bb:(td=f,f=$),f!==V?(a.length>td?(h=a.charAt(td),td++):(h=V,0===zd&&g(Cc)),h!==V?(ud=e,f=Rc(h),e=f):(td=e,e=$)):(td=e,e=$);d!==V?(a.substr(td,2)===Pc?(e=Pc,td+=2):(e=V,0===zd&&g(Qc)),e!==V?(ud=b,c=Sc(d),b=c):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(Mc)),b}function L(){var b,c,d,e,f,h;if(zd++,b=td,a.substr(td,2)===Uc?(c=Uc,td+=2):(c=V,0===zd&&g(Vc)),c!==V){for(d=[],e=td,f=td,zd++,a.substr(td,2)===Wc?(h=Wc,td+=2):(h=V,0===zd&&g(Xc)),zd--,h===V?f=bb:(td=f,f=$),f!==V?(a.length>td?(h=a.charAt(td),td++):(h=V,0===zd&&g(Cc)),h!==V?(ud=e,f=Dc(h),e=f):(td=e,e=$)):(td=e,e=$);e!==V;)d.push(e),e=td,f=td,zd++,a.substr(td,2)===Wc?(h=Wc,td+=2):(h=V,0===zd&&g(Xc)),zd--,h===V?f=bb:(td=f,f=$),f!==V?(a.length>td?(h=a.charAt(td),td++):(h=V,0===zd&&g(Cc)),h!==V?(ud=e,f=Dc(h),e=f):(td=e,e=$)):(td=e,e=$);d!==V?(a.substr(td,2)===Wc?(e=Wc,td+=2):(e=V,0===zd&&g(Xc)),e!==V?(ud=b,c=Yc(d),b=c):(td=b,b=$)):(td=b,b=$)}else td=b,b=$;return zd--,b===V&&(c=V,0===zd&&g(Tc)),b}function M(){var b,c,d,e,f,h,i,j,k,l;if(b=td,c=N(),c!==V){for(d=[],e=S();e!==V;)d.push(e),e=S();if(d!==V)if(Zc.test(a.charAt(td))?(e=a.charAt(td),td++):(e=V,0===zd&&g($c)),e!==V){for(f=[],h=S();h!==V;)f.push(h),h=S();if(f!==V){if(h=[],i=td,j=td,zd++,k=O(),zd--,k===V?j=bb:(td=j,j=$),j!==V?(k=td,zd++,l=R(),zd--,l===V?k=bb:(td=k,k=$),k!==V?(a.length>td?(l=a.charAt(td),td++):(l=V,0===zd&&g(Cc)),l!==V?(j=[j,k,l],i=j):(td=i,i=$)):(td=i,i=$)):(td=i,i=$),i!==V)for(;i!==V;)h.push(i),i=td,j=td,zd++,k=O(),zd--,k===V?j=bb:(td=j,j=$),j!==V?(k=td,zd++,l=R(),zd--,l===V?k=bb:(td=k,k=$),k!==V?(a.length>td?(l=a.charAt(td),td++):(l=V,0===zd&&g(Cc)),l!==V?(j=[j,k,l],i=j):(td=i,i=$)):(td=i,i=$)):(td=i,i=$);else h=$;if(h!==V){for(i=[],j=S();j!==V;)i.push(j),j=S();i!==V?(j=O(),j!==V?(c=[c,d,e,f,h,i,j],b=c):(td=b,b=$)):(td=b,b=$)}else td=b,b=$}else td=b,b=$}else td=b,b=$;else td=b,b=$}else td=b,b=$;return b===V&&(b=r()),b}function N(){var b;return 123===a.charCodeAt(td)?(b=_c,td++):(b=V,0===zd&&g(ad)),b}function O(){var b;return 125===a.charCodeAt(td)?(b=bd,td++):(b=V,0===zd&&g(cd)),b}function P(){var b;return 91===a.charCodeAt(td)?(b=dd,td++):(b=V,0===zd&&g(ed)),b}function Q(){var b;return 93===a.charCodeAt(td)?(b=fd,td++):(b=V,0===zd&&g(gd)),b}function R(){var b;return 10===a.charCodeAt(td)?(b=hd,td++):(b=V,0===zd&&g(id)),b===V&&(a.substr(td,2)===jd?(b=jd,td+=2):(b=V,0===zd&&g(kd)),b===V&&(13===a.charCodeAt(td)?(b=ld,td++):(b=V,0===zd&&g(md)),b===V&&(8232===a.charCodeAt(td)?(b=nd,td++):(b=V,0===zd&&g(od)),b===V&&(8233===a.charCodeAt(td)?(b=pd,td++):(b=V,0===zd&&g(qd)))))),b}function S(){var b;return rd.test(a.charAt(td))?(b=a.charAt(td),td++):(b=V,0===zd&&g(sd)),b===V&&(b=R()),b}var T,U=arguments.length>1?arguments[1]:{},V={},W={start:i},X=i,Y=function(a){return["body"].concat(a).concat([["line",c()],["col",d()]])},Z={type:"other",description:"section"},$=V,_=null,ab=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},bb=void 0,cb=function(a,b,e){return e.push(["param",["literal","block"],b]),a.push(e),a.concat([["line",c()],["col",d()]])},db="/",eb={type:"literal",value:"/",description:'"/"'},fb=function(a){return a.push(["bodies"]),a.concat([["line",c()],["col",d()]])},gb=/^[#?\^<+@%]/,hb={type:"class",value:"[#?\\^<+@%]",description:"[#?\\^<+@%]"},ib=function(a,b,c,d){return[a,b,c,d]},jb={type:"other",description:"end tag"},kb=function(a){return a},lb=":",mb={type:"literal",value:":",description:'":"'},nb=function(a){return a},ob=function(a){return a?["context",a]:["context"]},pb={type:"other",description:"params"},qb="=",rb={type:"literal",value:"=",description:'"="'},sb=function(a,b){return["param",["literal",a],b]},tb=function(a){return["params"].concat(a)},ub={type:"other",description:"bodies"},vb=function(a){return["bodies"].concat(a)},wb={type:"other",description:"reference"},xb=function(a,b){return["reference",a,b].concat([["line",c()],["col",d()]])},yb={type:"other",description:"partial"},zb=">",Ab={type:"literal",value:">",description:'">"'},Bb="+",Cb={type:"literal",value:"+",description:'"+"'},Db=function(a){return["literal",a]},Eb=function(a,b,e,f){var g=">"===a?"partial":a;return[g,b,e,f].concat([["line",c()],["col",d()]])},Fb={type:"other",description:"filters"},Gb="|",Hb={type:"literal",value:"|",description:'"|"'},Ib=function(a){return["filters"].concat(a)},Jb={type:"other",description:"special"},Kb="~",Lb={type:"literal",value:"~",description:'"~"'},Mb=function(a){return["special",a].concat([["line",c()],["col",d()]])},Nb={type:"other",description:"identifier"},Ob=function(a){var b=["path"].concat(a);return b.text=a[1].join(".").replace(/,line,\d+,col,\d+/g,""),b},Pb=function(a){var b=["key",a];return b.text=a,b},Qb={type:"other",description:"number"},Rb=function(a){return["literal",a]},Sb={type:"other",description:"float"},Tb=".",Ub={type:"literal",value:".",description:'"."'},Vb=function(a,b){return parseFloat(a+"."+b)},Wb={type:"other",description:"unsigned_integer"},Xb=/^[0-9]/,Yb={type:"class",value:"[0-9]",description:"[0-9]"},Zb=function(a){return parseInt(a.join(""),10)},$b={type:"other",description:"signed_integer"},_b="-",ac={type:"literal",value:"-",description:'"-"'},bc=function(a,b){return-1*b},cc={type:"other",description:"integer"},dc={type:"other",description:"path"},ec=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()]])},fc=function(a){return a.length>0?[!0,a[0]].concat([["line",c()],["col",d()]]):[!0,[]].concat([["line",c()],["col",d()]])},gc={type:"other",description:"key"},hc=/^[a-zA-Z_$]/,ic={type:"class",value:"[a-zA-Z_$]",description:"[a-zA-Z_$]"},jc=/^[0-9a-zA-Z_$\-]/,kc={type:"class",value:"[0-9a-zA-Z_$\\-]",description:"[0-9a-zA-Z_$\\-]"},lc=function(a,b){return a+b.join("")},mc={type:"other",description:"array"},nc=function(a){return a.join("")},oc=function(a){return a},pc=function(a,b){return b?b.unshift(a):b=[a],b},qc={type:"other",description:"array_part"},rc=function(a){return a},sc=function(a,b){return b?a.concat(b):a},tc={type:"other",description:"inline"},uc='"',vc={type:"literal",value:'"',description:'"\\""'},wc=function(){return["literal",""].concat([["line",c()],["col",d()]])},xc=function(a){return["literal",a].concat([["line",c()],["col",d()]])},yc=function(a){return["body"].concat(a).concat([["line",c()],["col",d()]])},zc=function(a){return["buffer",a]},Ac={type:"other",description:"buffer"},Bc=function(a,b){return["format",a,b.join("")].concat([["line",c()],["col",d()]])},Cc={type:"any",description:"any character"},Dc=function(a){return a},Ec=function(a){return["buffer",a.join("")].concat([["line",c()],["col",d()]])},Fc={type:"other",description:"literal"},Gc=/^[^"]/,Hc={type:"class",value:'[^"]',description:'[^"]'},Ic=function(a){return a.join("")},Jc='\\"',Kc={type:"literal",value:'\\"',description:'"\\\\\\""'},Lc=function(){return'"'},Mc={type:"other",description:"raw"},Nc="{`",Oc={type:"literal",value:"{`",description:'"{`"'},Pc="`}",Qc={type:"literal",value:"`}",description:'"`}"'},Rc=function(a){return a},Sc=function(a){return["raw",a.join("")].concat([["line",c()],["col",d()]])},Tc={type:"other",description:"comment"},Uc="{!",Vc={type:"literal",value:"{!",description:'"{!"'},Wc="!}",Xc={type:"literal",value:"!}",description:'"!}"'},Yc=function(a){return["comment",a.join("")].concat([["line",c()],["col",d()]])},Zc=/^[#?\^><+%:@\/~%]/,$c={type:"class",value:"[#?\\^><+%:@\\/~%]",description:"[#?\\^><+%:@\\/~%]"},_c="{",ad={type:"literal",value:"{",description:'"{"'},bd="}",cd={type:"literal",value:"}",description:'"}"'},dd="[",ed={type:"literal",value:"[",description:'"["'},fd="]",gd={type:"literal",value:"]",description:'"]"'},hd="\n",id={type:"literal",value:"\n",description:'"\\n"'},jd="\r\n",kd={type:"literal",value:"\r\n",description:'"\\r\\n"'},ld="\r",md={type:"literal",value:"\r",description:'"\\r"'},nd="\u2028",od={type:"literal",value:"\u2028",description:'"\\u2028"'},pd="\u2029",qd={type:"literal",value:"\u2029",description:'"\\u2029"'},rd=/^[\t\x0B\f \xA0\uFEFF]/,sd={type:"class",value:"[\\t\\x0B\\f \\xA0\\uFEFF]",description:"[\\t\\x0B\\f \\xA0\\uFEFF]"},td=0,ud=0,vd=0,wd={line:1,column:1,seenCR:!1},xd=0,yd=[],zd=0;if("startRule"in U){if(!(U.startRule in W))throw new Error("Can't start parsing from rule \""+U.startRule+'".');X=W[U.startRule]}if(T=X(),T!==V&&td===a.length)return T;throw T!==V&&td<a.length&&g({type:"end",description:"end of input"}),h(null,yd,xd)}return a(b,Error),{SyntaxError:b,parse:c}}();return dust.parse=a.parse,a}),function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define("dust.compile",["dust.core","dust.parse"],function(dust,a){return b(a,dust).compile}):"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 o.filterNode(b,a)}function c(a,b){var c,d,e,f=[b[0]];for(c=1,d=b.length;d>c;c++)e=o.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=o.filterNode(a,b[d]),f&&("buffer"===f[0]||"format"===f[0]?c?(c[0]="buffer"===f[0]?"buffer":c[0],c[1]+=f.slice(1,-2).join("")):(c=f,g.push(f)):(c=null,g.push(f)));return g}function e(a,b){return["buffer",q[b[1]],b[2],b[3]]}function f(a,b){return b}function g(){}function h(a,b){return dust.config.whitespace?(b.splice(1,2,b.slice(1,-2).join("")),b):null}function i(a,b){var c={name:b,bodies:[],blocks:{},index:0,auto:"h"},d=dust.escapeJs(b),e="function(dust){dust.register("+(b?'"'+d+'"':"null")+","+o.compileNode(c,a)+");"+j(c)+k(c)+"return body_0;}";return dust.config.amd?'define("'+d+'",["dust.core"],'+e+");":"("+e+")(dust);"}function j(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 k(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]+";}body_"+b+".__dustBody=!0;";return d.join("")}function l(a,b){var c,d,e="";for(c=1,d=b.length;d>c;c++)e+=o.compileNode(a,b[c]);return e}function m(a,b,c){return"."+(dust._aliases[c]||c)+"("+o.compileNode(a,b[1])+","+o.compileNode(a,b[2])+","+o.compileNode(a,b[4])+","+o.compileNode(a,b[3])+")"}function n(a){return a.replace(r,"\\\\").replace(s,'\\"').replace(t,"\\f").replace(u,"\\n").replace(v,"\\r").replace(w,"\\t")}var o={},p=dust.isArray;o.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 i(e,d)}catch(f){if(!f.line||!f.column)throw f;throw new SyntaxError(f.message+" At line : "+f.line+", column : "+f.column)}},o.filterNode=function(a,b){return o.optimizers[b[0]](a,b)},o.optimizers={body:d,buffer:f,special:e,format:h,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},o.pragmas={esc:function(a,b,c){var d,e=a.auto;return b||(b="h"),a.auto="s"===b?"":b,d=l(a,c.block),a.auto=e,d}};var q={s:" ",n:"\n",r:"\r",lb:"{",rb:"}"};o.compileNode=function(a,b){return o.nodes[b[0]](a,b)},o.nodes={body:function(a,b){var c=a.index++,d="body_"+c;return a.bodies[c]=l(a,b),d},buffer:function(a,b){return".w("+x(b[1])+")"},format:function(a,b){return".w("+x(b[1])+")"},reference:function(a,b){return".f("+o.compileNode(a,b[1])+",ctx,"+o.compileNode(a,b[2])+")"},"#":function(a,b){return m(a,b,"section")},"?":function(a,b){return m(a,b,"exists")},"^":function(a,b){return m(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]=o.compileNode(a,f[2]),""}return""},"+":function(a,b){return"undefined"==typeof b[1].text&&"undefined"==typeof b[4]?".block(ctx.getBlock("+o.compileNode(a,b[1])+",chk, ctx),"+o.compileNode(a,b[2])+", {},"+o.compileNode(a,b[3])+")":".block(ctx.getBlock("+x(b[1].text)+"),"+o.compileNode(a,b[2])+","+o.compileNode(a,b[4])+","+o.compileNode(a,b[3])+")"},"@":function(a,b){return".h("+x(b[1].text)+","+o.compileNode(a,b[2])+","+o.compileNode(a,b[4])+","+o.compileNode(a,b[3])+")"},"%":function(a,b){var c,d,e,f,g,h,i,j,k,l=b[1][1];if(!o.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,o.pragmas[l](a,g,d,f)},partial:function(a,b){return".p("+o.compileNode(a,b[1])+","+o.compileNode(a,b[2])+","+o.compileNode(a,b[3])+")"},context:function(a,b){return b[1]?"ctx.rebase("+o.compileNode(a,b[1])+")":"ctx"},params:function(a,b){for(var c=[],d=1,e=b.length;e>d;d++)c.push(o.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(o.compileNode(a,b[d]));return"{"+c.join(",")+"}"},param:function(a,b){return o.compileNode(a,b[1])+":"+o.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(p(d[f])?o.compileNode(a,d[f]):'"'+d[f]+'"');return"ctx.getPath("+c+", ["+e.join(",")+"])"},literal:function(a,b){return x(b[1])},raw:function(a,b){return".w("+x(b[1])+")"}};var r=/\\/g,s=/"/g,t=/\f/g,u=/\n/g,v=/\r/g,w=/\t/g,x="undefined"==typeof JSON?function(a){return'"'+n(a)+'"'}:JSON.stringify;return dust.compile=o.compile,dust.filterNode=o.filterNode,dust.optimizers=o.optimizers,dust.pragmas=o.pragmas,dust.compileNode=o.compileNode,dust.nodes=o.nodes,o}),"function"==typeof define&&define.amd&&define.amd.dust===!0&&define(["require","dust.core","dust.compile"],function(require,dust){return dust.onLoad=function(a,b){require([a],function(){b()})},dust}); |
479
lib/dust.js
@@ -1,19 +0,17 @@ | ||
/*jshint evil:true*/ | ||
(function(root) { | ||
(function (root, factory) { | ||
/*global define*/ | ||
if (typeof define === 'function' && define.amd && define.amd.dust === true) { | ||
define('dust.core', [], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(); | ||
} else { | ||
root.dust = factory(); | ||
} | ||
}(this, function() { | ||
var dust = { | ||
"version": "2.6.1" | ||
"version": "2.6.2" | ||
}, | ||
NONE = 'NONE', | ||
ERROR = 'ERROR', | ||
WARN = 'WARN', | ||
INFO = 'INFO', | ||
DEBUG = 'DEBUG', | ||
loggingLevels = [DEBUG, INFO, WARN, ERROR, NONE], | ||
EMPTY_FUNC = function() {}, | ||
logger = {}, | ||
originalLog, | ||
loggerContext; | ||
NONE = 'NONE', ERROR = 'ERROR', WARN = 'WARN', INFO = 'INFO', DEBUG = 'DEBUG', | ||
EMPTY_FUNC = function() {}; | ||
dust.debugLevel = NONE; | ||
dust.config = { | ||
@@ -39,44 +37,44 @@ whitespace: false, | ||
// Try to find the console in global scope | ||
if (root && root.console && root.console.log) { | ||
loggerContext = root.console; | ||
originalLog = root.console.log; | ||
} | ||
(function initLogging() { | ||
/*global process, console*/ | ||
var loggingLevels = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, NONE: 4 }, | ||
consoleLog, | ||
log; | ||
// robust logger for node.js, modern browsers, and IE <= 9. | ||
logger.log = loggerContext ? function() { | ||
// Do this for normal browsers | ||
if (typeof originalLog === 'function') { | ||
logger.log = function() { | ||
originalLog.apply(loggerContext, arguments); | ||
if (typeof console !== 'undefined' && console.log) { | ||
consoleLog = console.log; | ||
if(typeof consoleLog === 'function') { | ||
log = function() { | ||
consoleLog.apply(console, arguments); | ||
}; | ||
} else { | ||
// Do this for IE <= 9 | ||
logger.log = function() { | ||
var message = Array.prototype.slice.apply(arguments).join(' '); | ||
originalLog(message); | ||
log = function() { | ||
consoleLog(Array.prototype.slice.apply(arguments).join(' ')); | ||
}; | ||
} | ||
logger.log.apply(this, arguments); | ||
} : function() { /* no op */ }; | ||
} else { | ||
log = EMPTY_FUNC; | ||
} | ||
/** | ||
* Log dust debug statements, info statements, warning statements, and errors. | ||
* Filters out the messages based on the dust.debuglevel. | ||
* This default implementation will print to the console if it exists. | ||
* @param {String|Error} message the message to print/throw | ||
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG) | ||
* @public | ||
*/ | ||
dust.log = function(message, type) { | ||
type = type || INFO; | ||
if (dust.debugLevel !== NONE && dust.indexInArray(loggingLevels, type) >= dust.indexInArray(loggingLevels, dust.debugLevel)) { | ||
if(!dust.logQueue) { | ||
dust.logQueue = []; | ||
/** | ||
* Filters messages based on `dust.debugLevel`. | ||
* This default implementation will print to the console if it exists. | ||
* @param {String|Error} message the message to print/throw | ||
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG) | ||
* @public | ||
*/ | ||
dust.log = function(message, type) { | ||
type = type || INFO; | ||
if (loggingLevels[type] >= loggingLevels[dust.debugLevel]) { | ||
log('[DUST:' + type + ']', message); | ||
} | ||
dust.logQueue.push({message: message, type: type}); | ||
logger.log('[DUST:' + type + ']', message); | ||
}; | ||
dust.debugLevel = NONE; | ||
if(typeof process !== 'undefined' && process.env && /\bdust\b/.test(process.env.DEBUG)) { | ||
dust.debugLevel = DEBUG; | ||
} | ||
}; | ||
}()); | ||
dust.helpers = {}; | ||
@@ -119,5 +117,10 @@ | ||
/** | ||
* Compile a template to an invokable function. | ||
* If `name` is provided, also registers the template under `name`. | ||
* @param source {String} template source | ||
* @param [name] {String} template name | ||
* @return {Function} has the signature `fn(context, cb)` | ||
*/ | ||
dust.compileFn = function(source, name) { | ||
// name is optional. When name is not provided the template can only be rendered using the callable returned by this function. | ||
// If a name is provided the compiled template can also be rendered by name. | ||
name = name || null; | ||
@@ -130,6 +133,5 @@ var tmpl = dust.loadSource(dust.compile(source, name)); | ||
tmpl(master.head, Context.wrap(context, name)).end(); | ||
} else { | ||
dust.log(new Error('Template `' + name + '` could not be loaded'), ERROR); | ||
} | ||
else { | ||
dust.log(new Error('Template [' + name + '] cannot be resolved to a Dust function'), ERROR); | ||
} | ||
}); | ||
@@ -163,2 +165,3 @@ return master; | ||
dust.loadSource = function(source, path) { | ||
/*jshint evil:true*/ | ||
return eval(source); | ||
@@ -175,36 +178,2 @@ }; | ||
// indexOf shim for arrays for IE <= 8 | ||
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf | ||
dust.indexInArray = function(arr, item, fromIndex) { | ||
fromIndex = +fromIndex || 0; | ||
if (Array.prototype.indexOf) { | ||
return arr.indexOf(item, fromIndex); | ||
} else { | ||
if ( arr === undefined || arr === null ) { | ||
throw new TypeError( 'cannot call method "indexOf" of null' ); | ||
} | ||
var length = arr.length; // Hack to convert object.length to a UInt32 | ||
if (Math.abs(fromIndex) === Infinity) { | ||
fromIndex = 0; | ||
} | ||
if (fromIndex < 0) { | ||
fromIndex += length; | ||
if (fromIndex < 0) { | ||
fromIndex = 0; | ||
} | ||
} | ||
for (;fromIndex < length; fromIndex++) { | ||
if (arr[fromIndex] === item) { | ||
return fromIndex; | ||
} | ||
} | ||
return -1; | ||
} | ||
}; | ||
dust.nextTick = (function() { | ||
@@ -216,17 +185,52 @@ return function(callback) { | ||
/** | ||
* Dust has its own rules for what is "empty"-- which is not the same as falsy. | ||
* Empty arrays, null, and undefined are empty | ||
*/ | ||
dust.isEmpty = function(value) { | ||
if (value === 0) { | ||
return false; | ||
} | ||
if (dust.isArray(value) && !value.length) { | ||
return true; | ||
} | ||
if (value === 0) { | ||
return !value; | ||
}; | ||
dust.isEmptyObject = function(obj) { | ||
var key; | ||
if (obj === null) { | ||
return false; | ||
} | ||
return (!value); | ||
if (obj === undefined) { | ||
return false; | ||
} | ||
if (obj.length > 0) { | ||
return false; | ||
} | ||
for (key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Decide somewhat-naively if something is a Thenable. | ||
* @param elem {*} object to inspect | ||
* @return {Boolean} is `elem` a Thenable? | ||
*/ | ||
dust.isThenable = function(elem) { | ||
return elem && | ||
typeof elem === 'object' && | ||
typeof elem.then === 'function'; | ||
}; | ||
// apply the filter chain and return the output string | ||
dust.filter = function(string, auto, filters) { | ||
var i, len, name; | ||
if (filters) { | ||
for (var i=0, len=filters.length; i<len; i++) { | ||
var name = filters[i]; | ||
for (i = 0, len = filters.length; i < len; i++) { | ||
name = filters[i]; | ||
if (name === 's') { | ||
@@ -239,3 +243,3 @@ auto = null; | ||
else { | ||
dust.log('Invalid filter [' + name + ']', WARN); | ||
dust.log('Invalid filter `' + name + '`', WARN); | ||
} | ||
@@ -258,3 +262,3 @@ } | ||
jp: function(value) { | ||
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN); | ||
if (!JSON) {dust.log('JSON is undefined; could not parse `' + value + '`', WARN); | ||
return value; | ||
@@ -268,3 +272,3 @@ } else { | ||
function Context(stack, global, blocks, templateName) { | ||
this.stack = stack; | ||
this.stack = stack; | ||
this.global = global; | ||
@@ -279,2 +283,14 @@ this.blocks = blocks; | ||
/** | ||
* Factory function that creates a closure scope around a Thenable-callback. | ||
* Returns a function that can be passed to a Thenable that will resume a | ||
* Context lookup once the Thenable resolves with new data, adding that new | ||
* data to the lookup stack. | ||
*/ | ||
function getWithResolvedData(ctx, cur, down) { | ||
return function(data) { | ||
return ctx.push(data)._get(cur, down); | ||
}; | ||
} | ||
Context.wrap = function(context, name) { | ||
@@ -321,5 +337,6 @@ if (context instanceof Context) { | ||
Context.prototype._get = function(cur, down) { | ||
var ctx = this.stack, | ||
var ctx = this.stack || {}, | ||
i = 1, | ||
value, first, len, ctxThis, fn; | ||
first = down[0]; | ||
@@ -355,3 +372,3 @@ len = down.length; | ||
} else { | ||
//context's head is empty, value we are searching for is not defined | ||
// context's head is empty, value we are searching for is not defined | ||
ctx = undefined; | ||
@@ -362,2 +379,6 @@ } | ||
while (ctx && i < len) { | ||
if (dust.isThenable(ctx)) { | ||
// Bail early by returning a Thenable for the remainder of the search tree | ||
return ctx.then(getWithResolvedData(this, cur, down.slice(i))); | ||
} | ||
ctxThis = ctx; | ||
@@ -369,3 +390,2 @@ ctx = ctx[down[i]]; | ||
// Return the ctx or a function wrapping the application of the context. | ||
if (typeof ctx === 'function') { | ||
@@ -384,3 +404,3 @@ fn = function() { | ||
if (ctx === undefined) { | ||
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']'); | ||
dust.log('Cannot find reference `{' + down.join('.') + '}` in template `' + this.getTemplateName() + '`', INFO); | ||
} | ||
@@ -399,2 +419,8 @@ return ctx; | ||
Context.prototype.pop = function() { | ||
var head = this.current(); | ||
this.stack = this.stack && this.stack.tail; | ||
return head; | ||
}; | ||
Context.prototype.rebase = function(head) { | ||
@@ -404,19 +430,27 @@ return new Context(new Stack(head), this.global, this.blocks, this.getTemplateName()); | ||
Context.prototype.clone = function() { | ||
var context = this.rebase(); | ||
context.stack = this.stack; | ||
return context; | ||
}; | ||
Context.prototype.current = function() { | ||
return this.stack.head; | ||
return this.stack && this.stack.head; | ||
}; | ||
Context.prototype.getBlock = function(key, chk, ctx) { | ||
var blocks, len, fn; | ||
if (typeof key === 'function') { | ||
var tempChk = new Chunk(); | ||
key = key(tempChk, this).data.join(''); | ||
key = key(new Chunk(), this).data.join(''); | ||
} | ||
var blocks = this.blocks; | ||
blocks = this.blocks; | ||
if (!blocks) { | ||
dust.log('No blocks for context[{' + key + '}] in template [' + this.getTemplateName() + ']', DEBUG); | ||
return; | ||
dust.log('No blocks for context `' + key + '` in template `' + this.getTemplateName() + '`', DEBUG); | ||
return false; | ||
} | ||
var len = blocks.length, fn; | ||
len = blocks.length; | ||
while (len--) { | ||
@@ -428,2 +462,5 @@ fn = blocks[len][key]; | ||
} | ||
dust.log('Malformed template `' + this.getTemplateName() + '` was missing one or more blocks.'); | ||
return false; | ||
}; | ||
@@ -446,2 +483,15 @@ | ||
Context.prototype.resolve = function(body) { | ||
var chunk; | ||
if(typeof body !== 'function') { | ||
return body; | ||
} | ||
chunk = new Chunk().render(body, this); | ||
if(!body.__dustBody) { | ||
return chunk; | ||
} | ||
return chunk.data.join(''); // ie7 perf | ||
}; | ||
Context.prototype.getTemplateName = function() { | ||
@@ -473,3 +523,3 @@ return this.templateName; | ||
this.callback(chunk.error); | ||
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN); | ||
dust.log('Rendering failed with error `' + chunk.error + '`', ERROR); | ||
this.flush = EMPTY_FUNC; | ||
@@ -498,3 +548,3 @@ return; | ||
this.emit('error', chunk.error); | ||
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN); | ||
dust.log('Streaming failed with error `' + chunk.error + '`', ERROR); | ||
this.flush = EMPTY_FUNC; | ||
@@ -512,37 +562,25 @@ return; | ||
Stream.prototype.emit = function(type, data) { | ||
if (!this.events) { | ||
dust.log('No events to emit', INFO); | ||
return false; | ||
var events = this.events || {}, | ||
handlers = events[type] || [], | ||
i, l; | ||
if (!handlers.length) { | ||
dust.log('Stream broadcasting, but no listeners for `' + type + '`', DEBUG); | ||
return; | ||
} | ||
var handler = this.events[type]; | ||
if (!handler) { | ||
dust.log('Event type [' + type + '] does not exist', WARN); | ||
return false; | ||
handlers = handlers.slice(0); | ||
for (i = 0, l = handlers.length; i < l; i++) { | ||
handlers[i](data); | ||
} | ||
if (typeof handler === 'function') { | ||
handler(data); | ||
} else if (dust.isArray(handler)) { | ||
var listeners = handler.slice(0); | ||
for (var i = 0, l = listeners.length; i < l; i++) { | ||
listeners[i](data); | ||
} | ||
} else { | ||
dust.log('Event Handler [' + handler + '] is not of a type that is handled by emit', WARN); | ||
} | ||
}; | ||
Stream.prototype.on = function(type, callback) { | ||
if (!this.events) { | ||
this.events = {}; | ||
} | ||
if (!this.events[type]) { | ||
if(callback) { | ||
this.events[type] = callback; | ||
} else { | ||
dust.log('Callback for type [' + type + '] does not exist. Listener not registered.', WARN); | ||
} | ||
} else if(typeof this.events[type] === 'function') { | ||
this.events[type] = [this.events[type], callback]; | ||
var events = this.events = this.events || {}, | ||
handlers = events[type] = events[type] || []; | ||
if(typeof callback !== 'function') { | ||
dust.log('No callback function provided for `' + type + '` event listener', WARN); | ||
} else { | ||
this.events[type].push(callback); | ||
handlers.push(callback); | ||
} | ||
@@ -553,3 +591,4 @@ return this; | ||
Stream.prototype.pipe = function(stream) { | ||
this.on('data', function(data) { | ||
return this | ||
.on('data', function(data) { | ||
try { | ||
@@ -560,12 +599,13 @@ stream.write(data, 'utf8'); | ||
} | ||
}).on('end', function() { | ||
}) | ||
.on('end', function() { | ||
try { | ||
return stream.end(); | ||
stream.end(); | ||
} catch (err) { | ||
dust.log(err, ERROR); | ||
} | ||
}).on('error', function(err) { | ||
}) | ||
.on('error', function(err) { | ||
stream.error(err); | ||
}); | ||
return this; | ||
}; | ||
@@ -582,3 +622,3 @@ | ||
Chunk.prototype.write = function(data) { | ||
var taps = this.taps; | ||
var taps = this.taps; | ||
@@ -609,5 +649,5 @@ if (taps) { | ||
callback(branch); | ||
} catch(e) { | ||
dust.log(e, ERROR); | ||
branch.setError(e); | ||
} catch(err) { | ||
dust.log(err, ERROR); | ||
branch.setError(err); | ||
} | ||
@@ -639,4 +679,2 @@ return cursor; | ||
if (typeof elem === 'function') { | ||
// Changed the function calling to use apply with the current context to make sure | ||
// that "this" is wat we expect it to be inside the function | ||
elem = elem.apply(context.current(), [this, context, null, {auto: auto, filters: filters}]); | ||
@@ -647,3 +685,5 @@ if (elem instanceof Chunk) { | ||
} | ||
if (!dust.isEmpty(elem)) { | ||
if (dust.isThenable(elem)) { | ||
return this.await(elem, context); | ||
} else if (!dust.isEmpty(elem)) { | ||
return this.write(dust.filter(elem, auto, filters)); | ||
@@ -656,12 +696,16 @@ } else { | ||
Chunk.prototype.section = function(elem, context, bodies, params) { | ||
// anonymous functions | ||
var body = bodies.block, | ||
skip = bodies['else'], | ||
chunk = this, | ||
i, len; | ||
if (typeof elem === 'function' && !elem.__dustBody) { | ||
try { | ||
elem = elem.apply(context.current(), [this, context, bodies, params]); | ||
} catch(e) { | ||
dust.log(e, ERROR); | ||
return this.setError(e); | ||
} catch(err) { | ||
dust.log(err, ERROR); | ||
return this.setError(err); | ||
} | ||
// 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 | ||
// Functions that return chunks are assumed to have handled the chunk manually. | ||
// Make that chunk the current one and go to the next method in the chain. | ||
if (elem instanceof Chunk) { | ||
@@ -671,7 +715,4 @@ return elem; | ||
} | ||
var body = bodies.block, | ||
skip = bodies['else']; | ||
// a.k.a Inline parameters in the Dust documentations | ||
if (params) { | ||
if (!dust.isEmptyObject(params)) { | ||
context = context.push(params); | ||
@@ -685,13 +726,11 @@ } | ||
*/ | ||
//non empty array is truthy, empty array is falsy | ||
if (dust.isArray(elem)) { | ||
if (body) { | ||
var len = elem.length, chunk = this; | ||
len = elem.length; | ||
if (len > 0) { | ||
// any custom helper can blow up the stack | ||
// and store a flattened context, guard defensively | ||
// any custom helper can blow up the stack and store a flattened context, guard defensively | ||
if(context.stack.head) { | ||
context.stack.head['$len'] = len; | ||
} | ||
for (var i=0; i<len; i++) { | ||
for (i = 0; i < len; i++) { | ||
if(context.stack.head) { | ||
@@ -712,3 +751,5 @@ context.stack.head['$idx'] = i; | ||
} | ||
} else if (elem === true) { | ||
} else if (dust.isThenable(elem)) { | ||
return this.await(elem, context, bodies); | ||
} else if (elem === true) { | ||
// true is truthy but does not change context | ||
@@ -730,3 +771,3 @@ if (body) { | ||
} | ||
dust.log('Not rendering section (#) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG); | ||
dust.log('Section without corresponding key in template `' + context.getTemplateName() + '`', DEBUG); | ||
return this; | ||
@@ -743,6 +784,6 @@ }; | ||
} | ||
dust.log('No block for exists check in template `' + context.getTemplateName() + '`', DEBUG); | ||
} else if (skip) { | ||
return skip(this, context); | ||
} | ||
dust.log('Not rendering exists (?) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG); | ||
return this; | ||
@@ -759,6 +800,6 @@ }; | ||
} | ||
dust.log('No block for not-exists check in template `' + context.getTemplateName() + '`', DEBUG); | ||
} else if (skip) { | ||
return skip(this, context); | ||
} | ||
dust.log('Not rendering not exists (^) block check in template [' + context.getTemplateName() + '], because above key was found', DEBUG); | ||
return this; | ||
@@ -768,8 +809,4 @@ }; | ||
Chunk.prototype.block = function(elem, context, bodies) { | ||
var body = bodies.block; | ||
var body = elem || bodies.block; | ||
if (elem) { | ||
body = elem; | ||
} | ||
if (body) { | ||
@@ -782,47 +819,41 @@ return body(this, context); | ||
Chunk.prototype.partial = function(elem, context, params) { | ||
var partialContext; | ||
//put the params context second to match what section does. {.} matches the current context without parameters | ||
// start with an empty context | ||
partialContext = dust.makeBase(context.global); | ||
partialContext.blocks = context.blocks; | ||
if (context.stack && context.stack.tail){ | ||
// grab the stack(tail) off of the previous context if we have it | ||
partialContext.stack = context.stack.tail; | ||
} | ||
if (params){ | ||
//put params on | ||
partialContext = partialContext.push(params); | ||
} | ||
var head; | ||
if(typeof elem === 'string') { | ||
partialContext.templateName = elem; | ||
if (!dust.isEmptyObject(params)) { | ||
context = context.clone(); | ||
head = context.pop(); | ||
context = context.push(params) | ||
.push(head); | ||
} | ||
//reattach the head | ||
partialContext = partialContext.push(context.stack.head); | ||
var partialChunk; | ||
if (typeof elem === 'function') { | ||
partialChunk = this.capture(elem, partialContext, function(name, chunk) { | ||
partialContext.templateName = partialContext.templateName || name; | ||
dust.load(name, chunk, partialContext).end(); | ||
if (elem.__dustBody) { | ||
// The eventual result of evaluating `elem` is a partial name | ||
// Load the partial after getting its name and end the async chunk | ||
return this.capture(elem, context, function(name, chunk) { | ||
context.templateName = name; | ||
dust.load(name, chunk, context).end(); | ||
}); | ||
} else { | ||
partialChunk = dust.load(elem, this, partialContext); | ||
context.templateName = elem; | ||
return dust.load(elem, this, context); | ||
} | ||
return partialChunk; | ||
}; | ||
Chunk.prototype.helper = function(name, context, bodies, params) { | ||
var chunk = this; | ||
var chunk = this, | ||
ret; | ||
// handle invalid helpers, similar to invalid filters | ||
if(dust.helpers[name]) { | ||
try { | ||
return dust.helpers[name](chunk, context, bodies, params); | ||
} catch(e) { | ||
dust.log('Error in ' + name + ' helper: ' + e, ERROR); | ||
return chunk.setError(e); | ||
ret = dust.helpers[name](chunk, context, bodies, params); | ||
if (dust.isThenable(ret)) { | ||
return this.await(ret, context, bodies); | ||
} | ||
return ret; | ||
} catch(err) { | ||
dust.log('Error in helper `' + name + '`: ' + err.message, ERROR); | ||
return chunk.setError(err); | ||
} | ||
} else { | ||
dust.log('Invalid helper [' + name + ']', WARN); | ||
dust.log('Helper `' + name + '` does not exist', WARN); | ||
return chunk; | ||
@@ -832,2 +863,30 @@ } | ||
/** | ||
* Reserve a chunk to be evaluated once a thenable is resolved or rejected | ||
* @param thenable {Thenable} the target thenable to await | ||
* @param context {Context} context to use to render the deferred chunk | ||
* @param bodies {Object} must contain a "body", may contain an "error" | ||
* @return {Chunk} | ||
*/ | ||
Chunk.prototype.await = function(thenable, context, bodies) { | ||
var body = bodies && bodies.block, | ||
errorBody = bodies && bodies.error; | ||
return this.map(function(chunk) { | ||
thenable.then(function(data) { | ||
if(body) { | ||
chunk.render(body, context.push(data)).end(); | ||
} else { | ||
chunk.end(data); | ||
} | ||
}, function(err) { | ||
if(errorBody) { | ||
chunk.render(errorBody, context.push(err)).end(); | ||
} else { | ||
dust.log('Unhandled promise rejection in `' + context.getTemplateName() + '`'); | ||
chunk.end(); | ||
} | ||
}); | ||
}); | ||
}; | ||
Chunk.prototype.capture = function(body, context, callback) { | ||
@@ -928,3 +987,3 @@ return this.map(function(chunk) { | ||
if (!JSON) { | ||
dust.log('JSON is undefined. JSON stringify has not been used on [' + o + ']', WARN); | ||
dust.log('JSON is undefined; could not escape `' + o + '`', WARN); | ||
return o; | ||
@@ -939,12 +998,4 @@ } else { | ||
if (typeof define === "function" && define.amd && define.amd.dust === true) { | ||
define("dust.core", function() { | ||
return dust; | ||
}); | ||
} else if (typeof exports === 'object') { | ||
module.exports = dust; | ||
} else { | ||
root.dust = dust; | ||
} | ||
return dust; | ||
})((function(){return this;})()); | ||
})); |
@@ -17,5 +17,2 @@ ## What's all this here | ||
### server.js | ||
There is one more file in lib: **server.js** (see package.json). This file is the entry point for Node environments. | ||
### dust-core pre-compiling files and keeping a slim runtime | ||
@@ -27,3 +24,3 @@ For browser performance, we recommend providing only the **dust-core.js** file to the browser and compiling templates on the server. | ||
### dust-full when you need to compile | ||
When you need to compile templates, that is take files written in Dust syntax and converting them to things that can be `dust.render`'ed, you'll need **dust-full.js**. The **compiler.js** and **parser.js** file are included with **dust.js** in **dust-full.js** in order to provide the compile functionality. | ||
When you need to compile templates, that is take files written in Dust syntax and converting them to things that can be `dust.render`'ed, you'll need **dust-full.js**. The **compiler.js** and **parser.js** file are included with **dust.js** in **dust-full.js** in order to provide the compile functionality. | ||
@@ -35,3 +32,3 @@ You should provide **dust-full.js** to the browser if you are compiling templates on demand or if simply just don't want to pre-compile on the server and perf does not matter. | ||
### Server vs Browser - the server file | ||
Dust is written to run on both the server and the browser. In truth, it is written to work first on the browser and modified to work on the server. | ||
Dust is written to run on both the server and the browser. In truth, it is written to work first on the browser and modified to work on the server. | ||
@@ -41,3 +38,3 @@ A few things are added to make it work on the server: | ||
* A UMD style wrapper is added to all the files so that, for example, `dust` is returned to `module.exports` in Node whereas it would have returned as `window.dust` in the browser | ||
* Servers that use npm (Node) need a single main entry point. For us, this is **server.js** which sets up `dust-full` by pulling in the necessary lib modules, modifies some methods to work in Node, and exports it as a module. | ||
* Servers that use npm (Node) need a single main entry point. For us, this is **index.js** which sets up `dust-full` by pulling in the necessary lib modules, modifies some methods to work in Node, and exports it as a module. | ||
* Browsers don't need to be a single file but to make it easier a build script is setup so that the necessary lib files are combined into **dist/dust-full.js** and **dist/dust-core.js**. |
{ | ||
"name": "dustjs-linkedin", | ||
"title": "Dust - Asynchronous Templating", | ||
"version": "2.6.1", | ||
"version": "2.6.2", | ||
"author": { | ||
@@ -28,3 +28,3 @@ "name": "Aleksander Williams", | ||
}, | ||
"main": "lib/server.js", | ||
"main": "index.js", | ||
"browser": "./lib/dust.js", | ||
@@ -44,19 +44,21 @@ "repository": { | ||
"dependencies": { | ||
"chokidar": "~1.0.0-rc4", | ||
"cli": "~0.6.5" | ||
}, | ||
"devDependencies": { | ||
"ayepromise": "~1.1.1", | ||
"grunt": "~0.4.2", | ||
"grunt-bump": "0.0.11", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"grunt-contrib-concat": "~0.3.0", | ||
"grunt-contrib-connect": "~0.5.0", | ||
"grunt-contrib-copy": "~0.4.1", | ||
"grunt-contrib-jasmine": "~0.5.2", | ||
"grunt-contrib-jshint": "~0.7.2", | ||
"grunt-contrib-uglify": "~0.2.7", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"grunt-gh-pages": "~0.9.0", | ||
"grunt-jasmine-node": "~0.2.1", | ||
"grunt-shell": "~0.6.1", | ||
"grunt-template-jasmine-istanbul": "~0.2.5", | ||
"grunt-bump": "0.3.0", | ||
"grunt-contrib-clean": "~0.6.0", | ||
"grunt-contrib-concat": "~0.5.1", | ||
"grunt-contrib-connect": "~0.9.0", | ||
"grunt-contrib-copy": "~0.8.0", | ||
"grunt-contrib-jasmine": "~0.8.2", | ||
"grunt-contrib-jshint": "~0.11.1", | ||
"grunt-contrib-uglify": "~0.8.0", | ||
"grunt-contrib-watch": "~0.6.1", | ||
"grunt-gh-pages": "~0.10.0", | ||
"grunt-jasmine-nodejs": "~1.0.2", | ||
"grunt-shell": "~1.1.2", | ||
"grunt-template-jasmine-istanbul": "~0.3.3", | ||
"pegjs": "0.8.0" | ||
@@ -63,0 +65,0 @@ }, |
@@ -1,62 +0,29 @@ | ||
Dust [![Build Status](https://secure.travis-ci.org/linkedin/dustjs.png)](http://travis-ci.org/linkedin/dustjs) | ||
==== | ||
This is the LinkedIn fork of Dust. | ||
# Dust.js [![Build Status](https://secure.travis-ci.org/linkedin/dustjs.png)](http://travis-ci.org/linkedin/dustjs) | ||
Asynchronous Javascript templating for the browser and server. This fork is maintained by [LinkedIn](http://linkedin.github.io/). | ||
## Getting Started | ||
A quick tutorial for how to use Dust <https://github.com/linkedin/dustjs/wiki/Dust-Tutorial> | ||
## Install | ||
More info <http://linkedin.github.io/dustjs/> and <http://linkedin.github.io/dustjs/#installation> | ||
### NPM | ||
npm install --save dustjs-linkedin | ||
# If you want the dustc compiler available globally | ||
npm install -g dustjs-linkedin | ||
## More | ||
Read more here: <http://linkedin.github.com/dustjs/>. | ||
If you want to add the [Dust helpers](https://github.com/linkedin/dustjs-helpers) or [secure filters](https://github.com/linkedin/dustjs-filters-secure): | ||
For LinkedIn dust-helpers: <https://github.com/linkedin/dustjs-helpers>. | ||
npm install --save dustjs-helpers | ||
npm install --save dustjs-filters-secure | ||
For LinkedIn secure-filters : <https://github.com/linkedin/dustjs-filters-secure>. | ||
### Bower | ||
bower install --save dustjs-linkedin | ||
## Building Dust locally | ||
### Grab a copy of the repo | ||
``` | ||
cd some_project_directory | ||
git clone https://github.com/linkedin/dustjs.git dustjs | ||
cd dustjs | ||
## Get Started | ||
``` | ||
* Read [dustjs.com](http://www.dustjs.com/) for guides, tutorials, and documentation. | ||
* Check out the `examples/` directory in the repo for simple examples to help you get started using Dust in a variety of ways. | ||
### (Optional) Install Grunt-cli | ||
* Grunt-cli lets you run Grunt from within a subfolder see http://gruntjs.com/getting-started | ||
``` | ||
npm install -g grunt-cli | ||
``` | ||
## Contribute | ||
### Fetch all node dependencies | ||
``` | ||
npm install | ||
``` | ||
### Run tests | ||
``` | ||
grunt test | ||
``` | ||
## Contributing to Dust | ||
* Setup a branch for what you are working on | ||
git checkout -b myBranchName | ||
* Test your changes (jshint, unit tests in node, rhino and phantom and make sure test coverage thresholds are met) | ||
grunt test | ||
* Use `grunt dev` while developing\debugging. | ||
This task will start a server and serve Jasmine spec runner on http://localhost:3000/_SpecRunner.html. | ||
This task uses unminified dust-full.js so it allows you to easily step through the code in a browser. | ||
* Use `grunt testClient` to test production version of code (dust-full.min.js) in a browser. | ||
Similarly to `grunt dev` it serves Jasmine spec runner on `http://localhost:3000/_SpecRunner.html`. | ||
* Add unit tests. Unit tests can be found in the `test/jasmine-tests/spec` directory. Help us keep up good test coverage! To view coverage report run `grunt coverage` and open `tmp/coverage/index.html` in a browser. | ||
* Add an issue and send a pull request. Pull requests are easier to track if you also include an issue. Sending a pull request from a branch makes it easier for you to resolve conflicts in master | ||
* The team provides support on [Stack Overflow](https://stackoverflow.com/questions/tagged/dust.js), so that's the best place to ask questions. | ||
* Bug or feature? We welcome issues and pull requests! If you'd like to submit a PR, check out the guide to [contributing](https://github.com/linkedin/dustjs/wiki/Contributing). PRs should include unit tests. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
690047
85
17552
2
16
5
30
34
8
+ Addedchokidar@~1.0.0-rc4
+ Addedanymatch@1.3.2(transitive)
+ Addedarr-diff@2.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarray-unique@0.2.1(transitive)
+ Addedarrify@1.0.1(transitive)
+ Addedasync-each@0.1.6(transitive)
+ Addedbinary-extensions@1.13.1(transitive)
+ Addedbraces@1.8.5(transitive)
+ Addedchokidar@1.0.6(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedexpand-brackets@0.1.5(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextglob@0.3.2(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.4(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedfsevents@0.3.8(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@1.3.02.0.0(transitive)
+ Addedgraceful-fs@4.1.15(transitive)
+ Addedis-binary-path@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@1.1.32.0.1(transitive)
+ Addedis-number@2.1.04.0.0(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedisobject@2.1.0(transitive)
+ Addedkind-of@3.2.26.0.3(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.11(transitive)
+ Addedminimatch@0.2.14(transitive)
+ Addednan@2.22.0(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedreaddirp@1.4.0(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedstring_decoder@0.10.31(transitive)