handlebars-v2.0.0.js 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079
  1. /*!
  2. handlebars v2.0.0
  3. Copyright (C) 2011-2014 by Yehuda Katz
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. @license
  20. */
  21. /* exported Handlebars */
  22. (function (root, factory) {
  23. if (typeof define === 'function' && define.amd) {
  24. define([], factory);
  25. } else if (typeof exports === 'object') {
  26. module.exports = factory();
  27. } else {
  28. root.Handlebars = root.Handlebars || factory();
  29. }
  30. }(this, function () {
  31. // handlebars/safe-string.js
  32. var __module4__ = (function() {
  33. "use strict";
  34. var __exports__;
  35. // Build out our basic SafeString type
  36. function SafeString(string) {
  37. this.string = string;
  38. }
  39. SafeString.prototype.toString = function() {
  40. return "" + this.string;
  41. };
  42. __exports__ = SafeString;
  43. return __exports__;
  44. })();
  45. // handlebars/utils.js
  46. var __module3__ = (function(__dependency1__) {
  47. "use strict";
  48. var __exports__ = {};
  49. /*jshint -W004 */
  50. var SafeString = __dependency1__;
  51. var escape = {
  52. "&": "&",
  53. "<": "&lt;",
  54. ">": "&gt;",
  55. '"': "&quot;",
  56. "'": "&#x27;",
  57. "`": "&#x60;"
  58. };
  59. var badChars = /[&<>"'`]/g;
  60. var possible = /[&<>"'`]/;
  61. function escapeChar(chr) {
  62. return escape[chr];
  63. }
  64. function extend(obj /* , ...source */) {
  65. for (var i = 1; i < arguments.length; i++) {
  66. for (var key in arguments[i]) {
  67. if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
  68. obj[key] = arguments[i][key];
  69. }
  70. }
  71. }
  72. return obj;
  73. }
  74. __exports__.extend = extend;var toString = Object.prototype.toString;
  75. __exports__.toString = toString;
  76. // Sourced from lodash
  77. // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
  78. var isFunction = function(value) {
  79. return typeof value === 'function';
  80. };
  81. // fallback for older versions of Chrome and Safari
  82. /* istanbul ignore next */
  83. if (isFunction(/x/)) {
  84. isFunction = function(value) {
  85. return typeof value === 'function' && toString.call(value) === '[object Function]';
  86. };
  87. }
  88. var isFunction;
  89. __exports__.isFunction = isFunction;
  90. /* istanbul ignore next */
  91. var isArray = Array.isArray || function(value) {
  92. return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
  93. };
  94. __exports__.isArray = isArray;
  95. function escapeExpression(string) {
  96. // don't escape SafeStrings, since they're already safe
  97. if (string instanceof SafeString) {
  98. return string.toString();
  99. } else if (string == null) {
  100. return "";
  101. } else if (!string) {
  102. return string + '';
  103. }
  104. // Force a string conversion as this will be done by the append regardless and
  105. // the regex test will do this transparently behind the scenes, causing issues if
  106. // an object's to string has escaped characters in it.
  107. string = "" + string;
  108. if(!possible.test(string)) { return string; }
  109. return string.replace(badChars, escapeChar);
  110. }
  111. __exports__.escapeExpression = escapeExpression;function isEmpty(value) {
  112. if (!value && value !== 0) {
  113. return true;
  114. } else if (isArray(value) && value.length === 0) {
  115. return true;
  116. } else {
  117. return false;
  118. }
  119. }
  120. __exports__.isEmpty = isEmpty;function appendContextPath(contextPath, id) {
  121. return (contextPath ? contextPath + '.' : '') + id;
  122. }
  123. __exports__.appendContextPath = appendContextPath;
  124. return __exports__;
  125. })(__module4__);
  126. // handlebars/exception.js
  127. var __module5__ = (function() {
  128. "use strict";
  129. var __exports__;
  130. var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
  131. function Exception(message, node) {
  132. var line;
  133. if (node && node.firstLine) {
  134. line = node.firstLine;
  135. message += ' - ' + line + ':' + node.firstColumn;
  136. }
  137. var tmp = Error.prototype.constructor.call(this, message);
  138. // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
  139. for (var idx = 0; idx < errorProps.length; idx++) {
  140. this[errorProps[idx]] = tmp[errorProps[idx]];
  141. }
  142. if (line) {
  143. this.lineNumber = line;
  144. this.column = node.firstColumn;
  145. }
  146. }
  147. Exception.prototype = new Error();
  148. __exports__ = Exception;
  149. return __exports__;
  150. })();
  151. // handlebars/base.js
  152. var __module2__ = (function(__dependency1__, __dependency2__) {
  153. "use strict";
  154. var __exports__ = {};
  155. var Utils = __dependency1__;
  156. var Exception = __dependency2__;
  157. var VERSION = "2.0.0";
  158. __exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
  159. __exports__.COMPILER_REVISION = COMPILER_REVISION;
  160. var REVISION_CHANGES = {
  161. 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
  162. 2: '== 1.0.0-rc.3',
  163. 3: '== 1.0.0-rc.4',
  164. 4: '== 1.x.x',
  165. 5: '== 2.0.0-alpha.x',
  166. 6: '>= 2.0.0-beta.1'
  167. };
  168. __exports__.REVISION_CHANGES = REVISION_CHANGES;
  169. var isArray = Utils.isArray,
  170. isFunction = Utils.isFunction,
  171. toString = Utils.toString,
  172. objectType = '[object Object]';
  173. function HandlebarsEnvironment(helpers, partials) {
  174. this.helpers = helpers || {};
  175. this.partials = partials || {};
  176. registerDefaultHelpers(this);
  177. }
  178. __exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {
  179. constructor: HandlebarsEnvironment,
  180. logger: logger,
  181. log: log,
  182. registerHelper: function(name, fn) {
  183. if (toString.call(name) === objectType) {
  184. if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
  185. Utils.extend(this.helpers, name);
  186. } else {
  187. this.helpers[name] = fn;
  188. }
  189. },
  190. unregisterHelper: function(name) {
  191. delete this.helpers[name];
  192. },
  193. registerPartial: function(name, partial) {
  194. if (toString.call(name) === objectType) {
  195. Utils.extend(this.partials, name);
  196. } else {
  197. this.partials[name] = partial;
  198. }
  199. },
  200. unregisterPartial: function(name) {
  201. delete this.partials[name];
  202. }
  203. };
  204. function registerDefaultHelpers(instance) {
  205. instance.registerHelper('helperMissing', function(/* [args, ]options */) {
  206. if(arguments.length === 1) {
  207. // A missing field in a {{foo}} constuct.
  208. return undefined;
  209. } else {
  210. // Someone is actually trying to call something, blow up.
  211. throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
  212. }
  213. });
  214. instance.registerHelper('blockHelperMissing', function(context, options) {
  215. var inverse = options.inverse,
  216. fn = options.fn;
  217. if(context === true) {
  218. return fn(this);
  219. } else if(context === false || context == null) {
  220. return inverse(this);
  221. } else if (isArray(context)) {
  222. if(context.length > 0) {
  223. if (options.ids) {
  224. options.ids = [options.name];
  225. }
  226. return instance.helpers.each(context, options);
  227. } else {
  228. return inverse(this);
  229. }
  230. } else {
  231. if (options.data && options.ids) {
  232. var data = createFrame(options.data);
  233. data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
  234. options = {data: data};
  235. }
  236. return fn(context, options);
  237. }
  238. });
  239. instance.registerHelper('each', function(context, options) {
  240. if (!options) {
  241. throw new Exception('Must pass iterator to #each');
  242. }
  243. var fn = options.fn, inverse = options.inverse;
  244. var i = 0, ret = "", data;
  245. var contextPath;
  246. if (options.data && options.ids) {
  247. contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
  248. }
  249. if (isFunction(context)) { context = context.call(this); }
  250. if (options.data) {
  251. data = createFrame(options.data);
  252. }
  253. if(context && typeof context === 'object') {
  254. if (isArray(context)) {
  255. for(var j = context.length; i<j; i++) {
  256. if (data) {
  257. data.index = i;
  258. data.first = (i === 0);
  259. data.last = (i === (context.length-1));
  260. if (contextPath) {
  261. data.contextPath = contextPath + i;
  262. }
  263. }
  264. ret = ret + fn(context[i], { data: data });
  265. }
  266. } else {
  267. for(var key in context) {
  268. if(context.hasOwnProperty(key)) {
  269. if(data) {
  270. data.key = key;
  271. data.index = i;
  272. data.first = (i === 0);
  273. if (contextPath) {
  274. data.contextPath = contextPath + key;
  275. }
  276. }
  277. ret = ret + fn(context[key], {data: data});
  278. i++;
  279. }
  280. }
  281. }
  282. }
  283. if(i === 0){
  284. ret = inverse(this);
  285. }
  286. return ret;
  287. });
  288. instance.registerHelper('if', function(conditional, options) {
  289. if (isFunction(conditional)) { conditional = conditional.call(this); }
  290. // Default behavior is to render the positive path if the value is truthy and not empty.
  291. // The `includeZero` option may be set to treat the condtional as purely not empty based on the
  292. // behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
  293. if ((!options.hash.includeZero && !conditional) || Utils.isEmpty(conditional)) {
  294. return options.inverse(this);
  295. } else {
  296. return options.fn(this);
  297. }
  298. });
  299. instance.registerHelper('unless', function(conditional, options) {
  300. return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
  301. });
  302. instance.registerHelper('with', function(context, options) {
  303. if (isFunction(context)) { context = context.call(this); }
  304. var fn = options.fn;
  305. if (!Utils.isEmpty(context)) {
  306. if (options.data && options.ids) {
  307. var data = createFrame(options.data);
  308. data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
  309. options = {data:data};
  310. }
  311. return fn(context, options);
  312. } else {
  313. return options.inverse(this);
  314. }
  315. });
  316. instance.registerHelper('log', function(message, options) {
  317. var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
  318. instance.log(level, message);
  319. });
  320. instance.registerHelper('lookup', function(obj, field) {
  321. return obj && obj[field];
  322. });
  323. }
  324. var logger = {
  325. methodMap: { 0: 'debug', 1: 'info', 2: 'warn', 3: 'error' },
  326. // State enum
  327. DEBUG: 0,
  328. INFO: 1,
  329. WARN: 2,
  330. ERROR: 3,
  331. level: 3,
  332. // can be overridden in the host environment
  333. log: function(level, message) {
  334. if (logger.level <= level) {
  335. var method = logger.methodMap[level];
  336. if (typeof console !== 'undefined' && console[method]) {
  337. console[method].call(console, message);
  338. }
  339. }
  340. }
  341. };
  342. __exports__.logger = logger;
  343. var log = logger.log;
  344. __exports__.log = log;
  345. var createFrame = function(object) {
  346. var frame = Utils.extend({}, object);
  347. frame._parent = object;
  348. return frame;
  349. };
  350. __exports__.createFrame = createFrame;
  351. return __exports__;
  352. })(__module3__, __module5__);
  353. // handlebars/runtime.js
  354. var __module6__ = (function(__dependency1__, __dependency2__, __dependency3__) {
  355. "use strict";
  356. var __exports__ = {};
  357. var Utils = __dependency1__;
  358. var Exception = __dependency2__;
  359. var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
  360. var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
  361. var createFrame = __dependency3__.createFrame;
  362. function checkRevision(compilerInfo) {
  363. var compilerRevision = compilerInfo && compilerInfo[0] || 1,
  364. currentRevision = COMPILER_REVISION;
  365. if (compilerRevision !== currentRevision) {
  366. if (compilerRevision < currentRevision) {
  367. var runtimeVersions = REVISION_CHANGES[currentRevision],
  368. compilerVersions = REVISION_CHANGES[compilerRevision];
  369. throw new Exception("Template was precompiled with an older version of Handlebars than the current runtime. "+
  370. "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").");
  371. } else {
  372. // Use the embedded version info since the runtime doesn't know about this revision yet
  373. throw new Exception("Template was precompiled with a newer version of Handlebars than the current runtime. "+
  374. "Please update your runtime to a newer version ("+compilerInfo[1]+").");
  375. }
  376. }
  377. }
  378. __exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
  379. function template(templateSpec, env) {
  380. /* istanbul ignore next */
  381. if (!env) {
  382. throw new Exception("No environment passed to template");
  383. }
  384. if (!templateSpec || !templateSpec.main) {
  385. throw new Exception('Unknown template object: ' + typeof templateSpec);
  386. }
  387. // Note: Using env.VM references rather than local var references throughout this section to allow
  388. // for external users to override these as psuedo-supported APIs.
  389. env.VM.checkRevision(templateSpec.compiler);
  390. var invokePartialWrapper = function(partial, indent, name, context, hash, helpers, partials, data, depths) {
  391. if (hash) {
  392. context = Utils.extend({}, context, hash);
  393. }
  394. var result = env.VM.invokePartial.call(this, partial, name, context, helpers, partials, data, depths);
  395. if (result == null && env.compile) {
  396. var options = { helpers: helpers, partials: partials, data: data, depths: depths };
  397. partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
  398. result = partials[name](context, options);
  399. }
  400. if (result != null) {
  401. if (indent) {
  402. var lines = result.split('\n');
  403. for (var i = 0, l = lines.length; i < l; i++) {
  404. if (!lines[i] && i + 1 === l) {
  405. break;
  406. }
  407. lines[i] = indent + lines[i];
  408. }
  409. result = lines.join('\n');
  410. }
  411. return result;
  412. } else {
  413. throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
  414. }
  415. };
  416. // Just add water
  417. var container = {
  418. lookup: function(depths, name) {
  419. var len = depths.length;
  420. for (var i = 0; i < len; i++) {
  421. if (depths[i] && depths[i][name] != null) {
  422. return depths[i][name];
  423. }
  424. }
  425. },
  426. lambda: function(current, context) {
  427. return typeof current === 'function' ? current.call(context) : current;
  428. },
  429. escapeExpression: Utils.escapeExpression,
  430. invokePartial: invokePartialWrapper,
  431. fn: function(i) {
  432. return templateSpec[i];
  433. },
  434. programs: [],
  435. program: function(i, data, depths) {
  436. var programWrapper = this.programs[i],
  437. fn = this.fn(i);
  438. if (data || depths) {
  439. programWrapper = program(this, i, fn, data, depths);
  440. } else if (!programWrapper) {
  441. programWrapper = this.programs[i] = program(this, i, fn);
  442. }
  443. return programWrapper;
  444. },
  445. data: function(data, depth) {
  446. while (data && depth--) {
  447. data = data._parent;
  448. }
  449. return data;
  450. },
  451. merge: function(param, common) {
  452. var ret = param || common;
  453. if (param && common && (param !== common)) {
  454. ret = Utils.extend({}, common, param);
  455. }
  456. return ret;
  457. },
  458. noop: env.VM.noop,
  459. compilerInfo: templateSpec.compiler
  460. };
  461. var ret = function(context, options) {
  462. options = options || {};
  463. var data = options.data;
  464. ret._setup(options);
  465. if (!options.partial && templateSpec.useData) {
  466. data = initData(context, data);
  467. }
  468. var depths;
  469. if (templateSpec.useDepths) {
  470. depths = options.depths ? [context].concat(options.depths) : [context];
  471. }
  472. return templateSpec.main.call(container, context, container.helpers, container.partials, data, depths);
  473. };
  474. ret.isTop = true;
  475. ret._setup = function(options) {
  476. if (!options.partial) {
  477. container.helpers = container.merge(options.helpers, env.helpers);
  478. if (templateSpec.usePartial) {
  479. container.partials = container.merge(options.partials, env.partials);
  480. }
  481. } else {
  482. container.helpers = options.helpers;
  483. container.partials = options.partials;
  484. }
  485. };
  486. ret._child = function(i, data, depths) {
  487. if (templateSpec.useDepths && !depths) {
  488. throw new Exception('must pass parent depths');
  489. }
  490. return program(container, i, templateSpec[i], data, depths);
  491. };
  492. return ret;
  493. }
  494. __exports__.template = template;function program(container, i, fn, data, depths) {
  495. var prog = function(context, options) {
  496. options = options || {};
  497. return fn.call(container, context, container.helpers, container.partials, options.data || data, depths && [context].concat(depths));
  498. };
  499. prog.program = i;
  500. prog.depth = depths ? depths.length : 0;
  501. return prog;
  502. }
  503. __exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data, depths) {
  504. var options = { partial: true, helpers: helpers, partials: partials, data: data, depths: depths };
  505. if(partial === undefined) {
  506. throw new Exception("The partial " + name + " could not be found");
  507. } else if(partial instanceof Function) {
  508. return partial(context, options);
  509. }
  510. }
  511. __exports__.invokePartial = invokePartial;function noop() { return ""; }
  512. __exports__.noop = noop;function initData(context, data) {
  513. if (!data || !('root' in data)) {
  514. data = data ? createFrame(data) : {};
  515. data.root = context;
  516. }
  517. return data;
  518. }
  519. return __exports__;
  520. })(__module3__, __module5__, __module2__);
  521. // handlebars.runtime.js
  522. var __module1__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
  523. "use strict";
  524. var __exports__;
  525. /*globals Handlebars: true */
  526. var base = __dependency1__;
  527. // Each of these augment the Handlebars object. No need to setup here.
  528. // (This is done to easily share code between commonjs and browse envs)
  529. var SafeString = __dependency2__;
  530. var Exception = __dependency3__;
  531. var Utils = __dependency4__;
  532. var runtime = __dependency5__;
  533. // For compatibility and usage outside of module systems, make the Handlebars object a namespace
  534. var create = function() {
  535. var hb = new base.HandlebarsEnvironment();
  536. Utils.extend(hb, base);
  537. hb.SafeString = SafeString;
  538. hb.Exception = Exception;
  539. hb.Utils = Utils;
  540. hb.escapeExpression = Utils.escapeExpression;
  541. hb.VM = runtime;
  542. hb.template = function(spec) {
  543. return runtime.template(spec, hb);
  544. };
  545. return hb;
  546. };
  547. var Handlebars = create();
  548. Handlebars.create = create;
  549. Handlebars['default'] = Handlebars;
  550. __exports__ = Handlebars;
  551. return __exports__;
  552. })(__module2__, __module4__, __module5__, __module3__, __module6__);
  553. // handlebars/compiler/ast.js
  554. var __module7__ = (function(__dependency1__) {
  555. "use strict";
  556. var __exports__;
  557. var Exception = __dependency1__;
  558. function LocationInfo(locInfo) {
  559. locInfo = locInfo || {};
  560. this.firstLine = locInfo.first_line;
  561. this.firstColumn = locInfo.first_column;
  562. this.lastColumn = locInfo.last_column;
  563. this.lastLine = locInfo.last_line;
  564. }
  565. var AST = {
  566. ProgramNode: function(statements, strip, locInfo) {
  567. LocationInfo.call(this, locInfo);
  568. this.type = "program";
  569. this.statements = statements;
  570. this.strip = strip;
  571. },
  572. MustacheNode: function(rawParams, hash, open, strip, locInfo) {
  573. LocationInfo.call(this, locInfo);
  574. this.type = "mustache";
  575. this.strip = strip;
  576. // Open may be a string parsed from the parser or a passed boolean flag
  577. if (open != null && open.charAt) {
  578. // Must use charAt to support IE pre-10
  579. var escapeFlag = open.charAt(3) || open.charAt(2);
  580. this.escaped = escapeFlag !== '{' && escapeFlag !== '&';
  581. } else {
  582. this.escaped = !!open;
  583. }
  584. if (rawParams instanceof AST.SexprNode) {
  585. this.sexpr = rawParams;
  586. } else {
  587. // Support old AST API
  588. this.sexpr = new AST.SexprNode(rawParams, hash);
  589. }
  590. // Support old AST API that stored this info in MustacheNode
  591. this.id = this.sexpr.id;
  592. this.params = this.sexpr.params;
  593. this.hash = this.sexpr.hash;
  594. this.eligibleHelper = this.sexpr.eligibleHelper;
  595. this.isHelper = this.sexpr.isHelper;
  596. },
  597. SexprNode: function(rawParams, hash, locInfo) {
  598. LocationInfo.call(this, locInfo);
  599. this.type = "sexpr";
  600. this.hash = hash;
  601. var id = this.id = rawParams[0];
  602. var params = this.params = rawParams.slice(1);
  603. // a mustache is definitely a helper if:
  604. // * it is an eligible helper, and
  605. // * it has at least one parameter or hash segment
  606. this.isHelper = !!(params.length || hash);
  607. // a mustache is an eligible helper if:
  608. // * its id is simple (a single part, not `this` or `..`)
  609. this.eligibleHelper = this.isHelper || id.isSimple;
  610. // if a mustache is an eligible helper but not a definite
  611. // helper, it is ambiguous, and will be resolved in a later
  612. // pass or at runtime.
  613. },
  614. PartialNode: function(partialName, context, hash, strip, locInfo) {
  615. LocationInfo.call(this, locInfo);
  616. this.type = "partial";
  617. this.partialName = partialName;
  618. this.context = context;
  619. this.hash = hash;
  620. this.strip = strip;
  621. this.strip.inlineStandalone = true;
  622. },
  623. BlockNode: function(mustache, program, inverse, strip, locInfo) {
  624. LocationInfo.call(this, locInfo);
  625. this.type = 'block';
  626. this.mustache = mustache;
  627. this.program = program;
  628. this.inverse = inverse;
  629. this.strip = strip;
  630. if (inverse && !program) {
  631. this.isInverse = true;
  632. }
  633. },
  634. RawBlockNode: function(mustache, content, close, locInfo) {
  635. LocationInfo.call(this, locInfo);
  636. if (mustache.sexpr.id.original !== close) {
  637. throw new Exception(mustache.sexpr.id.original + " doesn't match " + close, this);
  638. }
  639. content = new AST.ContentNode(content, locInfo);
  640. this.type = 'block';
  641. this.mustache = mustache;
  642. this.program = new AST.ProgramNode([content], {}, locInfo);
  643. },
  644. ContentNode: function(string, locInfo) {
  645. LocationInfo.call(this, locInfo);
  646. this.type = "content";
  647. this.original = this.string = string;
  648. },
  649. HashNode: function(pairs, locInfo) {
  650. LocationInfo.call(this, locInfo);
  651. this.type = "hash";
  652. this.pairs = pairs;
  653. },
  654. IdNode: function(parts, locInfo) {
  655. LocationInfo.call(this, locInfo);
  656. this.type = "ID";
  657. var original = "",
  658. dig = [],
  659. depth = 0,
  660. depthString = '';
  661. for(var i=0,l=parts.length; i<l; i++) {
  662. var part = parts[i].part;
  663. original += (parts[i].separator || '') + part;
  664. if (part === ".." || part === "." || part === "this") {
  665. if (dig.length > 0) {
  666. throw new Exception("Invalid path: " + original, this);
  667. } else if (part === "..") {
  668. depth++;
  669. depthString += '../';
  670. } else {
  671. this.isScoped = true;
  672. }
  673. } else {
  674. dig.push(part);
  675. }
  676. }
  677. this.original = original;
  678. this.parts = dig;
  679. this.string = dig.join('.');
  680. this.depth = depth;
  681. this.idName = depthString + this.string;
  682. // an ID is simple if it only has one part, and that part is not
  683. // `..` or `this`.
  684. this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
  685. this.stringModeValue = this.string;
  686. },
  687. PartialNameNode: function(name, locInfo) {
  688. LocationInfo.call(this, locInfo);
  689. this.type = "PARTIAL_NAME";
  690. this.name = name.original;
  691. },
  692. DataNode: function(id, locInfo) {
  693. LocationInfo.call(this, locInfo);
  694. this.type = "DATA";
  695. this.id = id;
  696. this.stringModeValue = id.stringModeValue;
  697. this.idName = '@' + id.stringModeValue;
  698. },
  699. StringNode: function(string, locInfo) {
  700. LocationInfo.call(this, locInfo);
  701. this.type = "STRING";
  702. this.original =
  703. this.string =
  704. this.stringModeValue = string;
  705. },
  706. NumberNode: function(number, locInfo) {
  707. LocationInfo.call(this, locInfo);
  708. this.type = "NUMBER";
  709. this.original =
  710. this.number = number;
  711. this.stringModeValue = Number(number);
  712. },
  713. BooleanNode: function(bool, locInfo) {
  714. LocationInfo.call(this, locInfo);
  715. this.type = "BOOLEAN";
  716. this.bool = bool;
  717. this.stringModeValue = bool === "true";
  718. },
  719. CommentNode: function(comment, locInfo) {
  720. LocationInfo.call(this, locInfo);
  721. this.type = "comment";
  722. this.comment = comment;
  723. this.strip = {
  724. inlineStandalone: true
  725. };
  726. }
  727. };
  728. // Must be exported as an object rather than the root of the module as the jison lexer
  729. // most modify the object to operate properly.
  730. __exports__ = AST;
  731. return __exports__;
  732. })(__module5__);
  733. // handlebars/compiler/parser.js
  734. var __module9__ = (function() {
  735. "use strict";
  736. var __exports__;
  737. /* jshint ignore:start */
  738. /* istanbul ignore next */
  739. /* Jison generated parser */
  740. var handlebars = (function(){
  741. var parser = {trace: function trace() { },
  742. yy: {},
  743. symbols_: {"error":2,"root":3,"program":4,"EOF":5,"program_repetition0":6,"statement":7,"mustache":8,"block":9,"rawBlock":10,"partial":11,"CONTENT":12,"COMMENT":13,"openRawBlock":14,"END_RAW_BLOCK":15,"OPEN_RAW_BLOCK":16,"sexpr":17,"CLOSE_RAW_BLOCK":18,"openBlock":19,"block_option0":20,"closeBlock":21,"openInverse":22,"block_option1":23,"OPEN_BLOCK":24,"CLOSE":25,"OPEN_INVERSE":26,"inverseAndProgram":27,"INVERSE":28,"OPEN_ENDBLOCK":29,"path":30,"OPEN":31,"OPEN_UNESCAPED":32,"CLOSE_UNESCAPED":33,"OPEN_PARTIAL":34,"partialName":35,"param":36,"partial_option0":37,"partial_option1":38,"sexpr_repetition0":39,"sexpr_option0":40,"dataName":41,"STRING":42,"NUMBER":43,"BOOLEAN":44,"OPEN_SEXPR":45,"CLOSE_SEXPR":46,"hash":47,"hash_repetition_plus0":48,"hashSegment":49,"ID":50,"EQUALS":51,"DATA":52,"pathSegments":53,"SEP":54,"$accept":0,"$end":1},
  744. terminals_: {2:"error",5:"EOF",12:"CONTENT",13:"COMMENT",15:"END_RAW_BLOCK",16:"OPEN_RAW_BLOCK",18:"CLOSE_RAW_BLOCK",24:"OPEN_BLOCK",25:"CLOSE",26:"OPEN_INVERSE",28:"INVERSE",29:"OPEN_ENDBLOCK",31:"OPEN",32:"OPEN_UNESCAPED",33:"CLOSE_UNESCAPED",34:"OPEN_PARTIAL",42:"STRING",43:"NUMBER",44:"BOOLEAN",45:"OPEN_SEXPR",46:"CLOSE_SEXPR",50:"ID",51:"EQUALS",52:"DATA",54:"SEP"},
  745. productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[10,3],[14,3],[9,4],[9,4],[19,3],[22,3],[27,2],[21,3],[8,3],[8,3],[11,5],[11,4],[17,3],[17,1],[36,1],[36,1],[36,1],[36,1],[36,1],[36,3],[47,1],[49,3],[35,1],[35,1],[35,1],[41,2],[30,1],[53,3],[53,1],[6,0],[6,2],[20,0],[20,1],[23,0],[23,1],[37,0],[37,1],[38,0],[38,1],[39,0],[39,2],[40,0],[40,1],[48,1],[48,2]],
  746. performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
  747. var $0 = $$.length - 1;
  748. switch (yystate) {
  749. case 1: yy.prepareProgram($$[$0-1].statements, true); return $$[$0-1];
  750. break;
  751. case 2:this.$ = new yy.ProgramNode(yy.prepareProgram($$[$0]), {}, this._$);
  752. break;
  753. case 3:this.$ = $$[$0];
  754. break;
  755. case 4:this.$ = $$[$0];
  756. break;
  757. case 5:this.$ = $$[$0];
  758. break;
  759. case 6:this.$ = $$[$0];
  760. break;
  761. case 7:this.$ = new yy.ContentNode($$[$0], this._$);
  762. break;
  763. case 8:this.$ = new yy.CommentNode($$[$0], this._$);
  764. break;
  765. case 9:this.$ = new yy.RawBlockNode($$[$0-2], $$[$0-1], $$[$0], this._$);
  766. break;
  767. case 10:this.$ = new yy.MustacheNode($$[$0-1], null, '', '', this._$);
  768. break;
  769. case 11:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], false, this._$);
  770. break;
  771. case 12:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], true, this._$);
  772. break;
  773. case 13:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
  774. break;
  775. case 14:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
  776. break;
  777. case 15:this.$ = { strip: yy.stripFlags($$[$0-1], $$[$0-1]), program: $$[$0] };
  778. break;
  779. case 16:this.$ = {path: $$[$0-1], strip: yy.stripFlags($$[$0-2], $$[$0])};
  780. break;
  781. case 17:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
  782. break;
  783. case 18:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
  784. break;
  785. case 19:this.$ = new yy.PartialNode($$[$0-3], $$[$0-2], $$[$0-1], yy.stripFlags($$[$0-4], $$[$0]), this._$);
  786. break;
  787. case 20:this.$ = new yy.PartialNode($$[$0-2], undefined, $$[$0-1], yy.stripFlags($$[$0-3], $$[$0]), this._$);
  788. break;
  789. case 21:this.$ = new yy.SexprNode([$$[$0-2]].concat($$[$0-1]), $$[$0], this._$);
  790. break;
  791. case 22:this.$ = new yy.SexprNode([$$[$0]], null, this._$);
  792. break;
  793. case 23:this.$ = $$[$0];
  794. break;
  795. case 24:this.$ = new yy.StringNode($$[$0], this._$);
  796. break;
  797. case 25:this.$ = new yy.NumberNode($$[$0], this._$);
  798. break;
  799. case 26:this.$ = new yy.BooleanNode($$[$0], this._$);
  800. break;
  801. case 27:this.$ = $$[$0];
  802. break;
  803. case 28:$$[$0-1].isHelper = true; this.$ = $$[$0-1];
  804. break;
  805. case 29:this.$ = new yy.HashNode($$[$0], this._$);
  806. break;
  807. case 30:this.$ = [$$[$0-2], $$[$0]];
  808. break;
  809. case 31:this.$ = new yy.PartialNameNode($$[$0], this._$);
  810. break;
  811. case 32:this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0], this._$), this._$);
  812. break;
  813. case 33:this.$ = new yy.PartialNameNode(new yy.NumberNode($$[$0], this._$));
  814. break;
  815. case 34:this.$ = new yy.DataNode($$[$0], this._$);
  816. break;
  817. case 35:this.$ = new yy.IdNode($$[$0], this._$);
  818. break;
  819. case 36: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
  820. break;
  821. case 37:this.$ = [{part: $$[$0]}];
  822. break;
  823. case 38:this.$ = [];
  824. break;
  825. case 39:$$[$0-1].push($$[$0]);
  826. break;
  827. case 48:this.$ = [];
  828. break;
  829. case 49:$$[$0-1].push($$[$0]);
  830. break;
  831. case 52:this.$ = [$$[$0]];
  832. break;
  833. case 53:$$[$0-1].push($$[$0]);
  834. break;
  835. }
  836. },
  837. table: [{3:1,4:2,5:[2,38],6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],31:[2,38],32:[2,38],34:[2,38]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:[1,10],13:[1,11],14:16,16:[1,20],19:14,22:15,24:[1,18],26:[1,19],28:[2,2],29:[2,2],31:[1,12],32:[1,13],34:[1,17]},{1:[2,1]},{5:[2,39],12:[2,39],13:[2,39],16:[2,39],24:[2,39],26:[2,39],28:[2,39],29:[2,39],31:[2,39],32:[2,39],34:[2,39]},{5:[2,3],12:[2,3],13:[2,3],16:[2,3],24:[2,3],26:[2,3],28:[2,3],29:[2,3],31:[2,3],32:[2,3],34:[2,3]},{5:[2,4],12:[2,4],13:[2,4],16:[2,4],24:[2,4],26:[2,4],28:[2,4],29:[2,4],31:[2,4],32:[2,4],34:[2,4]},{5:[2,5],12:[2,5],13:[2,5],16:[2,5],24:[2,5],26:[2,5],28:[2,5],29:[2,5],31:[2,5],32:[2,5],34:[2,5]},{5:[2,6],12:[2,6],13:[2,6],16:[2,6],24:[2,6],26:[2,6],28:[2,6],29:[2,6],31:[2,6],32:[2,6],34:[2,6]},{5:[2,7],12:[2,7],13:[2,7],16:[2,7],24:[2,7],26:[2,7],28:[2,7],29:[2,7],31:[2,7],32:[2,7],34:[2,7]},{5:[2,8],12:[2,8],13:[2,8],16:[2,8],24:[2,8],26:[2,8],28:[2,8],29:[2,8],31:[2,8],32:[2,8],34:[2,8]},{17:21,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:27,30:22,41:23,50:[1,26],52:[1,25],53:24},{4:28,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{4:29,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{12:[1,30]},{30:32,35:31,42:[1,33],43:[1,34],50:[1,26],53:24},{17:35,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:36,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:37,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[1,38]},{18:[2,48],25:[2,48],33:[2,48],39:39,42:[2,48],43:[2,48],44:[2,48],45:[2,48],46:[2,48],50:[2,48],52:[2,48]},{18:[2,22],25:[2,22],33:[2,22],46:[2,22]},{18:[2,35],25:[2,35],33:[2,35],42:[2,35],43:[2,35],44:[2,35],45:[2,35],46:[2,35],50:[2,35],52:[2,35],54:[1,40]},{30:41,50:[1,26],53:24},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],52:[2,37],54:[2,37]},{33:[1,42]},{20:43,27:44,28:[1,45],29:[2,40]},{23:46,27:47,28:[1,45],29:[2,42]},{15:[1,48]},{25:[2,46],30:51,36:49,38:50,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],47:57,48:58,49:60,50:[1,59],52:[1,25],53:24},{25:[2,31],42:[2,31],43:[2,31],44:[2,31],45:[2,31],50:[2,31],52:[2,31]},{25:[2,32],42:[2,32],43:[2,32],44:[2,32],45:[2,32],50:[2,32],52:[2,32]},{25:[2,33],42:[2,33],43:[2,33],44:[2,33],45:[2,33],50:[2,33],52:[2,33]},{25:[1,61]},{25:[1,62]},{18:[1,63]},{5:[2,17],12:[2,17],13:[2,17],16:[2,17],24:[2,17],26:[2,17],28:[2,17],29:[2,17],31:[2,17],32:[2,17],34:[2,17]},{18:[2,50],25:[2,50],30:51,33:[2,50],36:65,40:64,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],46:[2,50],47:66,48:58,49:60,50:[1,59],52:[1,25],53:24},{50:[1,67]},{18:[2,34],25:[2,34],33:[2,34],42:[2,34],43:[2,34],44:[2,34],45:[2,34],46:[2,34],50:[2,34],52:[2,34]},{5:[2,18],12:[2,18],13:[2,18],16:[2,18],24:[2,18],26:[2,18],28:[2,18],29:[2,18],31:[2,18],32:[2,18],34:[2,18]},{21:68,29:[1,69]},{29:[2,41]},{4:70,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{21:71,29:[1,69]},{29:[2,43]},{5:[2,9],12:[2,9],13:[2,9],16:[2,9],24:[2,9],26:[2,9],28:[2,9],29:[2,9],31:[2,9],32:[2,9],34:[2,9]},{25:[2,44],37:72,47:73,48:58,49:60,50:[1,74]},{25:[1,75]},{18:[2,23],25:[2,23],33:[2,23],42:[2,23],43:[2,23],44:[2,23],45:[2,23],46:[2,23],50:[2,23],52:[2,23]},{18:[2,24],25:[2,24],33:[2,24],42:[2,24],43:[2,24],44:[2,24],45:[2,24],46:[2,24],50:[2,24],52:[2,24]},{18:[2,25],25:[2,25],33:[2,25],42:[2,25],43:[2,25],44:[2,25],45:[2,25],46:[2,25],50:[2,25],52:[2,25]},{18:[2,26],25:[2,26],33:[2,26],42:[2,26],43:[2,26],44:[2,26],45:[2,26],46:[2,26],50:[2,26],52:[2,26]},{18:[2,27],25:[2,27],33:[2,27],42:[2,27],43:[2,27],44:[2,27],45:[2,27],46:[2,27],50:[2,27],52:[2,27]},{17:76,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[2,47]},{18:[2,29],25:[2,29],33:[2,29],46:[2,29],49:77,50:[1,74]},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],51:[1,78],52:[2,37],54:[2,37]},{18:[2,52],25:[2,52],33:[2,52],46:[2,52],50:[2,52]},{12:[2,13],13:[2,13],16:[2,13],24:[2,13],26:[2,13],28:[2,13],29:[2,13],31:[2,13],32:[2,13],34:[2,13]},{12:[2,14],13:[2,14],16:[2,14],24:[2,14],26:[2,14],28:[2,14],29:[2,14],31:[2,14],32:[2,14],34:[2,14]},{12:[2,10]},{18:[2,21],25:[2,21],33:[2,21],46:[2,21]},{18:[2,49],25:[2,49],33:[2,49],42:[2,49],43:[2,49],44:[2,49],45:[2,49],46:[2,49],50:[2,49],52:[2,49]},{18:[2,51],25:[2,51],33:[2,51],46:[2,51]},{18:[2,36],25:[2,36],33:[2,36],42:[2,36],43:[2,36],44:[2,36],45:[2,36],46:[2,36],50:[2,36],52:[2,36],54:[2,36]},{5:[2,11],12:[2,11],13:[2,11],16:[2,11],24:[2,11],26:[2,11],28:[2,11],29:[2,11],31:[2,11],32:[2,11],34:[2,11]},{30:79,50:[1,26],53:24},{29:[2,15]},{5:[2,12],12:[2,12],13:[2,12],16:[2,12],24:[2,12],26:[2,12],28:[2,12],29:[2,12],31:[2,12],32:[2,12],34:[2,12]},{25:[1,80]},{25:[2,45]},{51:[1,78]},{5:[2,20],12:[2,20],13:[2,20],16:[2,20],24:[2,20],26:[2,20],28:[2,20],29:[2,20],31:[2,20],32:[2,20],34:[2,20]},{46:[1,81]},{18:[2,53],25:[2,53],33:[2,53],46:[2,53],50:[2,53]},{30:51,36:82,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],50:[1,26],52:[1,25],53:24},{25:[1,83]},{5:[2,19],12:[2,19],13:[2,19],16:[2,19],24:[2,19],26:[2,19],28:[2,19],29:[2,19],31:[2,19],32:[2,19],34:[2,19]},{18:[2,28],25:[2,28],33:[2,28],42:[2,28],43:[2,28],44:[2,28],45:[2,28],46:[2,28],50:[2,28],52:[2,28]},{18:[2,30],25:[2,30],33:[2,30],46:[2,30],50:[2,30]},{5:[2,16],12:[2,16],13:[2,16],16:[2,16],24:[2,16],26:[2,16],28:[2,16],29:[2,16],31:[2,16],32:[2,16],34:[2,16]}],
  838. defaultActions: {4:[2,1],44:[2,41],47:[2,43],57:[2,47],63:[2,10],70:[2,15],73:[2,45]},
  839. parseError: function parseError(str, hash) {
  840. throw new Error(str);
  841. },
  842. parse: function parse(input) {
  843. var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
  844. this.lexer.setInput(input);
  845. this.lexer.yy = this.yy;
  846. this.yy.lexer = this.lexer;
  847. this.yy.parser = this;
  848. if (typeof this.lexer.yylloc == "undefined")
  849. this.lexer.yylloc = {};
  850. var yyloc = this.lexer.yylloc;
  851. lstack.push(yyloc);
  852. var ranges = this.lexer.options && this.lexer.options.ranges;
  853. if (typeof this.yy.parseError === "function")
  854. this.parseError = this.yy.parseError;
  855. function popStack(n) {
  856. stack.length = stack.length - 2 * n;
  857. vstack.length = vstack.length - n;
  858. lstack.length = lstack.length - n;
  859. }
  860. function lex() {
  861. var token;
  862. token = self.lexer.lex() || 1;
  863. if (typeof token !== "number") {
  864. token = self.symbols_[token] || token;
  865. }
  866. return token;
  867. }
  868. var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
  869. while (true) {
  870. state = stack[stack.length - 1];
  871. if (this.defaultActions[state]) {
  872. action = this.defaultActions[state];
  873. } else {
  874. if (symbol === null || typeof symbol == "undefined") {
  875. symbol = lex();
  876. }
  877. action = table[state] && table[state][symbol];
  878. }
  879. if (typeof action === "undefined" || !action.length || !action[0]) {
  880. var errStr = "";
  881. if (!recovering) {
  882. expected = [];
  883. for (p in table[state])
  884. if (this.terminals_[p] && p > 2) {
  885. expected.push("'" + this.terminals_[p] + "'");
  886. }
  887. if (this.lexer.showPosition) {
  888. errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
  889. } else {
  890. errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
  891. }
  892. this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
  893. }
  894. }
  895. if (action[0] instanceof Array && action.length > 1) {
  896. throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
  897. }
  898. switch (action[0]) {
  899. case 1:
  900. stack.push(symbol);
  901. vstack.push(this.lexer.yytext);
  902. lstack.push(this.lexer.yylloc);
  903. stack.push(action[1]);
  904. symbol = null;
  905. if (!preErrorSymbol) {
  906. yyleng = this.lexer.yyleng;
  907. yytext = this.lexer.yytext;
  908. yylineno = this.lexer.yylineno;
  909. yyloc = this.lexer.yylloc;
  910. if (recovering > 0)
  911. recovering--;
  912. } else {
  913. symbol = preErrorSymbol;
  914. preErrorSymbol = null;
  915. }
  916. break;
  917. case 2:
  918. len = this.productions_[action[1]][1];
  919. yyval.$ = vstack[vstack.length - len];
  920. yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
  921. if (ranges) {
  922. yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
  923. }
  924. r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
  925. if (typeof r !== "undefined") {
  926. return r;
  927. }
  928. if (len) {
  929. stack = stack.slice(0, -1 * len * 2);
  930. vstack = vstack.slice(0, -1 * len);
  931. lstack = lstack.slice(0, -1 * len);
  932. }
  933. stack.push(this.productions_[action[1]][0]);
  934. vstack.push(yyval.$);
  935. lstack.push(yyval._$);
  936. newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
  937. stack.push(newState);
  938. break;
  939. case 3:
  940. return true;
  941. }
  942. }
  943. return true;
  944. }
  945. };
  946. /* Jison generated lexer */
  947. var lexer = (function(){
  948. var lexer = ({EOF:1,
  949. parseError:function parseError(str, hash) {
  950. if (this.yy.parser) {
  951. this.yy.parser.parseError(str, hash);
  952. } else {
  953. throw new Error(str);
  954. }
  955. },
  956. setInput:function (input) {
  957. this._input = input;
  958. this._more = this._less = this.done = false;
  959. this.yylineno = this.yyleng = 0;
  960. this.yytext = this.matched = this.match = '';
  961. this.conditionStack = ['INITIAL'];
  962. this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
  963. if (this.options.ranges) this.yylloc.range = [0,0];
  964. this.offset = 0;
  965. return this;
  966. },
  967. input:function () {
  968. var ch = this._input[0];
  969. this.yytext += ch;
  970. this.yyleng++;
  971. this.offset++;
  972. this.match += ch;
  973. this.matched += ch;
  974. var lines = ch.match(/(?:\r\n?|\n).*/g);
  975. if (lines) {
  976. this.yylineno++;
  977. this.yylloc.last_line++;
  978. } else {
  979. this.yylloc.last_column++;
  980. }
  981. if (this.options.ranges) this.yylloc.range[1]++;
  982. this._input = this._input.slice(1);
  983. return ch;
  984. },
  985. unput:function (ch) {
  986. var len = ch.length;
  987. var lines = ch.split(/(?:\r\n?|\n)/g);
  988. this._input = ch + this._input;
  989. this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
  990. //this.yyleng -= len;
  991. this.offset -= len;
  992. var oldLines = this.match.split(/(?:\r\n?|\n)/g);
  993. this.match = this.match.substr(0, this.match.length-1);
  994. this.matched = this.matched.substr(0, this.matched.length-1);
  995. if (lines.length-1) this.yylineno -= lines.length-1;
  996. var r = this.yylloc.range;
  997. this.yylloc = {first_line: this.yylloc.first_line,
  998. last_line: this.yylineno+1,
  999. first_column: this.yylloc.first_column,
  1000. last_column: lines ?
  1001. (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
  1002. this.yylloc.first_column - len
  1003. };
  1004. if (this.options.ranges) {
  1005. this.yylloc.range = [r[0], r[0] + this.yyleng - len];
  1006. }
  1007. return this;
  1008. },
  1009. more:function () {
  1010. this._more = true;
  1011. return this;
  1012. },
  1013. less:function (n) {
  1014. this.unput(this.match.slice(n));
  1015. },
  1016. pastInput:function () {
  1017. var past = this.matched.substr(0, this.matched.length - this.match.length);
  1018. return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
  1019. },
  1020. upcomingInput:function () {
  1021. var next = this.match;
  1022. if (next.length < 20) {
  1023. next += this._input.substr(0, 20-next.length);
  1024. }
  1025. return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
  1026. },
  1027. showPosition:function () {
  1028. var pre = this.pastInput();
  1029. var c = new Array(pre.length + 1).join("-");
  1030. return pre + this.upcomingInput() + "\n" + c+"^";
  1031. },
  1032. next:function () {
  1033. if (this.done) {
  1034. return this.EOF;
  1035. }
  1036. if (!this._input) this.done = true;
  1037. var token,
  1038. match,
  1039. tempMatch,
  1040. index,
  1041. col,
  1042. lines;
  1043. if (!this._more) {
  1044. this.yytext = '';
  1045. this.match = '';
  1046. }
  1047. var rules = this._currentRules();
  1048. for (var i=0;i < rules.length; i++) {
  1049. tempMatch = this._input.match(this.rules[rules[i]]);
  1050. if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
  1051. match = tempMatch;
  1052. index = i;
  1053. if (!this.options.flex) break;
  1054. }
  1055. }
  1056. if (match) {
  1057. lines = match[0].match(/(?:\r\n?|\n).*/g);
  1058. if (lines) this.yylineno += lines.length;
  1059. this.yylloc = {first_line: this.yylloc.last_line,
  1060. last_line: this.yylineno+1,
  1061. first_column: this.yylloc.last_column,
  1062. last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
  1063. this.yytext += match[0];
  1064. this.match += match[0];
  1065. this.matches = match;
  1066. this.yyleng = this.yytext.length;
  1067. if (this.options.ranges) {
  1068. this.yylloc.range = [this.offset, this.offset += this.yyleng];
  1069. }
  1070. this._more = false;
  1071. this._input = this._input.slice(match[0].length);
  1072. this.matched += match[0];
  1073. token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
  1074. if (this.done && this._input) this.done = false;
  1075. if (token) return token;
  1076. else return;
  1077. }
  1078. if (this._input === "") {
  1079. return this.EOF;
  1080. } else {
  1081. return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
  1082. {text: "", token: null, line: this.yylineno});
  1083. }
  1084. },
  1085. lex:function lex() {
  1086. var r = this.next();
  1087. if (typeof r !== 'undefined') {
  1088. return r;
  1089. } else {
  1090. return this.lex();
  1091. }
  1092. },
  1093. begin:function begin(condition) {
  1094. this.conditionStack.push(condition);
  1095. },
  1096. popState:function popState() {
  1097. return this.conditionStack.pop();
  1098. },
  1099. _currentRules:function _currentRules() {
  1100. return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
  1101. },
  1102. topState:function () {
  1103. return this.conditionStack[this.conditionStack.length-2];
  1104. },
  1105. pushState:function begin(condition) {
  1106. this.begin(condition);
  1107. }});
  1108. lexer.options = {};
  1109. lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
  1110. function strip(start, end) {
  1111. return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end);
  1112. }
  1113. var YYSTATE=YY_START
  1114. switch($avoiding_name_collisions) {
  1115. case 0:
  1116. if(yy_.yytext.slice(-2) === "\\\\") {
  1117. strip(0,1);
  1118. this.begin("mu");
  1119. } else if(yy_.yytext.slice(-1) === "\\") {
  1120. strip(0,1);
  1121. this.begin("emu");
  1122. } else {
  1123. this.begin("mu");
  1124. }
  1125. if(yy_.yytext) return 12;
  1126. break;
  1127. case 1:return 12;
  1128. break;
  1129. case 2:
  1130. this.popState();
  1131. return 12;
  1132. break;
  1133. case 3:
  1134. yy_.yytext = yy_.yytext.substr(5, yy_.yyleng-9);
  1135. this.popState();
  1136. return 15;
  1137. break;
  1138. case 4: return 12;
  1139. break;
  1140. case 5:strip(0,4); this.popState(); return 13;
  1141. break;
  1142. case 6:return 45;
  1143. break;
  1144. case 7:return 46;
  1145. break;
  1146. case 8: return 16;
  1147. break;
  1148. case 9:
  1149. this.popState();
  1150. this.begin('raw');
  1151. return 18;
  1152. break;
  1153. case 10:return 34;
  1154. break;
  1155. case 11:return 24;
  1156. break;
  1157. case 12:return 29;
  1158. break;
  1159. case 13:this.popState(); return 28;
  1160. break;
  1161. case 14:this.popState(); return 28;
  1162. break;
  1163. case 15:return 26;
  1164. break;
  1165. case 16:return 26;
  1166. break;
  1167. case 17:return 32;
  1168. break;
  1169. case 18:return 31;
  1170. break;
  1171. case 19:this.popState(); this.begin('com');
  1172. break;
  1173. case 20:strip(3,5); this.popState(); return 13;
  1174. break;
  1175. case 21:return 31;
  1176. break;
  1177. case 22:return 51;
  1178. break;
  1179. case 23:return 50;
  1180. break;
  1181. case 24:return 50;
  1182. break;
  1183. case 25:return 54;
  1184. break;
  1185. case 26:// ignore whitespace
  1186. break;
  1187. case 27:this.popState(); return 33;
  1188. break;
  1189. case 28:this.popState(); return 25;
  1190. break;
  1191. case 29:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 42;
  1192. break;
  1193. case 30:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 42;
  1194. break;
  1195. case 31:return 52;
  1196. break;
  1197. case 32:return 44;
  1198. break;
  1199. case 33:return 44;
  1200. break;
  1201. case 34:return 43;
  1202. break;
  1203. case 35:return 50;
  1204. break;
  1205. case 36:yy_.yytext = strip(1,2); return 50;
  1206. break;
  1207. case 37:return 'INVALID';
  1208. break;
  1209. case 38:return 5;
  1210. break;
  1211. }
  1212. };
  1213. lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{\/)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
  1214. lexer.conditions = {"mu":{"rules":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[5],"inclusive":false},"raw":{"rules":[3,4],"inclusive":false},"INITIAL":{"rules":[0,1,38],"inclusive":true}};
  1215. return lexer;})()
  1216. parser.lexer = lexer;
  1217. function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
  1218. return new Parser;
  1219. })();__exports__ = handlebars;
  1220. /* jshint ignore:end */
  1221. return __exports__;
  1222. })();
  1223. // handlebars/compiler/helpers.js
  1224. var __module10__ = (function(__dependency1__) {
  1225. "use strict";
  1226. var __exports__ = {};
  1227. var Exception = __dependency1__;
  1228. function stripFlags(open, close) {
  1229. return {
  1230. left: open.charAt(2) === '~',
  1231. right: close.charAt(close.length-3) === '~'
  1232. };
  1233. }
  1234. __exports__.stripFlags = stripFlags;
  1235. function prepareBlock(mustache, program, inverseAndProgram, close, inverted, locInfo) {
  1236. /*jshint -W040 */
  1237. if (mustache.sexpr.id.original !== close.path.original) {
  1238. throw new Exception(mustache.sexpr.id.original + ' doesn\'t match ' + close.path.original, mustache);
  1239. }
  1240. var inverse = inverseAndProgram && inverseAndProgram.program;
  1241. var strip = {
  1242. left: mustache.strip.left,
  1243. right: close.strip.right,
  1244. // Determine the standalone candiacy. Basically flag our content as being possibly standalone
  1245. // so our parent can determine if we actually are standalone
  1246. openStandalone: isNextWhitespace(program.statements),
  1247. closeStandalone: isPrevWhitespace((inverse || program).statements)
  1248. };
  1249. if (mustache.strip.right) {
  1250. omitRight(program.statements, null, true);
  1251. }
  1252. if (inverse) {
  1253. var inverseStrip = inverseAndProgram.strip;
  1254. if (inverseStrip.left) {
  1255. omitLeft(program.statements, null, true);
  1256. }
  1257. if (inverseStrip.right) {
  1258. omitRight(inverse.statements, null, true);
  1259. }
  1260. if (close.strip.left) {
  1261. omitLeft(inverse.statements, null, true);
  1262. }
  1263. // Find standalone else statments
  1264. if (isPrevWhitespace(program.statements)
  1265. && isNextWhitespace(inverse.statements)) {
  1266. omitLeft(program.statements);
  1267. omitRight(inverse.statements);
  1268. }
  1269. } else {
  1270. if (close.strip.left) {
  1271. omitLeft(program.statements, null, true);
  1272. }
  1273. }
  1274. if (inverted) {
  1275. return new this.BlockNode(mustache, inverse, program, strip, locInfo);
  1276. } else {
  1277. return new this.BlockNode(mustache, program, inverse, strip, locInfo);
  1278. }
  1279. }
  1280. __exports__.prepareBlock = prepareBlock;
  1281. function prepareProgram(statements, isRoot) {
  1282. for (var i = 0, l = statements.length; i < l; i++) {
  1283. var current = statements[i],
  1284. strip = current.strip;
  1285. if (!strip) {
  1286. continue;
  1287. }
  1288. var _isPrevWhitespace = isPrevWhitespace(statements, i, isRoot, current.type === 'partial'),
  1289. _isNextWhitespace = isNextWhitespace(statements, i, isRoot),
  1290. openStandalone = strip.openStandalone && _isPrevWhitespace,
  1291. closeStandalone = strip.closeStandalone && _isNextWhitespace,
  1292. inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace;
  1293. if (strip.right) {
  1294. omitRight(statements, i, true);
  1295. }
  1296. if (strip.left) {
  1297. omitLeft(statements, i, true);
  1298. }
  1299. if (inlineStandalone) {
  1300. omitRight(statements, i);
  1301. if (omitLeft(statements, i)) {
  1302. // If we are on a standalone node, save the indent info for partials
  1303. if (current.type === 'partial') {
  1304. current.indent = (/([ \t]+$)/).exec(statements[i-1].original) ? RegExp.$1 : '';
  1305. }
  1306. }
  1307. }
  1308. if (openStandalone) {
  1309. omitRight((current.program || current.inverse).statements);
  1310. // Strip out the previous content node if it's whitespace only
  1311. omitLeft(statements, i);
  1312. }
  1313. if (closeStandalone) {
  1314. // Always strip the next node
  1315. omitRight(statements, i);
  1316. omitLeft((current.inverse || current.program).statements);
  1317. }
  1318. }
  1319. return statements;
  1320. }
  1321. __exports__.prepareProgram = prepareProgram;function isPrevWhitespace(statements, i, isRoot) {
  1322. if (i === undefined) {
  1323. i = statements.length;
  1324. }
  1325. // Nodes that end with newlines are considered whitespace (but are special
  1326. // cased for strip operations)
  1327. var prev = statements[i-1],
  1328. sibling = statements[i-2];
  1329. if (!prev) {
  1330. return isRoot;
  1331. }
  1332. if (prev.type === 'content') {
  1333. return (sibling || !isRoot ? (/\r?\n\s*?$/) : (/(^|\r?\n)\s*?$/)).test(prev.original);
  1334. }
  1335. }
  1336. function isNextWhitespace(statements, i, isRoot) {
  1337. if (i === undefined) {
  1338. i = -1;
  1339. }
  1340. var next = statements[i+1],
  1341. sibling = statements[i+2];
  1342. if (!next) {
  1343. return isRoot;
  1344. }
  1345. if (next.type === 'content') {
  1346. return (sibling || !isRoot ? (/^\s*?\r?\n/) : (/^\s*?(\r?\n|$)/)).test(next.original);
  1347. }
  1348. }
  1349. // Marks the node to the right of the position as omitted.
  1350. // I.e. {{foo}}' ' will mark the ' ' node as omitted.
  1351. //
  1352. // If i is undefined, then the first child will be marked as such.
  1353. //
  1354. // If mulitple is truthy then all whitespace will be stripped out until non-whitespace
  1355. // content is met.
  1356. function omitRight(statements, i, multiple) {
  1357. var current = statements[i == null ? 0 : i + 1];
  1358. if (!current || current.type !== 'content' || (!multiple && current.rightStripped)) {
  1359. return;
  1360. }
  1361. var original = current.string;
  1362. current.string = current.string.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), '');
  1363. current.rightStripped = current.string !== original;
  1364. }
  1365. // Marks the node to the left of the position as omitted.
  1366. // I.e. ' '{{foo}} will mark the ' ' node as omitted.
  1367. //
  1368. // If i is undefined then the last child will be marked as such.
  1369. //
  1370. // If mulitple is truthy then all whitespace will be stripped out until non-whitespace
  1371. // content is met.
  1372. function omitLeft(statements, i, multiple) {
  1373. var current = statements[i == null ? statements.length - 1 : i - 1];
  1374. if (!current || current.type !== 'content' || (!multiple && current.leftStripped)) {
  1375. return;
  1376. }
  1377. // We omit the last node if it's whitespace only and not preceeded by a non-content node.
  1378. var original = current.string;
  1379. current.string = current.string.replace(multiple ? (/\s+$/) : (/[ \t]+$/), '');
  1380. current.leftStripped = current.string !== original;
  1381. return current.leftStripped;
  1382. }
  1383. return __exports__;
  1384. })(__module5__);
  1385. // handlebars/compiler/base.js
  1386. var __module8__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {
  1387. "use strict";
  1388. var __exports__ = {};
  1389. var parser = __dependency1__;
  1390. var AST = __dependency2__;
  1391. var Helpers = __dependency3__;
  1392. var extend = __dependency4__.extend;
  1393. __exports__.parser = parser;
  1394. var yy = {};
  1395. extend(yy, Helpers, AST);
  1396. function parse(input) {
  1397. // Just return if an already-compile AST was passed in.
  1398. if (input.constructor === AST.ProgramNode) { return input; }
  1399. parser.yy = yy;
  1400. return parser.parse(input);
  1401. }
  1402. __exports__.parse = parse;
  1403. return __exports__;
  1404. })(__module9__, __module7__, __module10__, __module3__);
  1405. // handlebars/compiler/compiler.js
  1406. var __module11__ = (function(__dependency1__, __dependency2__) {
  1407. "use strict";
  1408. var __exports__ = {};
  1409. var Exception = __dependency1__;
  1410. var isArray = __dependency2__.isArray;
  1411. var slice = [].slice;
  1412. function Compiler() {}
  1413. __exports__.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a
  1414. // function in a context. This is necessary for mustache compatibility, which
  1415. // requires that context functions in blocks are evaluated by blockHelperMissing,
  1416. // and then proceed as if the resulting value was provided to blockHelperMissing.
  1417. Compiler.prototype = {
  1418. compiler: Compiler,
  1419. equals: function(other) {
  1420. var len = this.opcodes.length;
  1421. if (other.opcodes.length !== len) {
  1422. return false;
  1423. }
  1424. for (var i = 0; i < len; i++) {
  1425. var opcode = this.opcodes[i],
  1426. otherOpcode = other.opcodes[i];
  1427. if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) {
  1428. return false;
  1429. }
  1430. }
  1431. // We know that length is the same between the two arrays because they are directly tied
  1432. // to the opcode behavior above.
  1433. len = this.children.length;
  1434. for (i = 0; i < len; i++) {
  1435. if (!this.children[i].equals(other.children[i])) {
  1436. return false;
  1437. }
  1438. }
  1439. return true;
  1440. },
  1441. guid: 0,
  1442. compile: function(program, options) {
  1443. this.opcodes = [];
  1444. this.children = [];
  1445. this.depths = {list: []};
  1446. this.options = options;
  1447. this.stringParams = options.stringParams;
  1448. this.trackIds = options.trackIds;
  1449. // These changes will propagate to the other compiler components
  1450. var knownHelpers = this.options.knownHelpers;
  1451. this.options.knownHelpers = {
  1452. 'helperMissing': true,
  1453. 'blockHelperMissing': true,
  1454. 'each': true,
  1455. 'if': true,
  1456. 'unless': true,
  1457. 'with': true,
  1458. 'log': true,
  1459. 'lookup': true
  1460. };
  1461. if (knownHelpers) {
  1462. for (var name in knownHelpers) {
  1463. this.options.knownHelpers[name] = knownHelpers[name];
  1464. }
  1465. }
  1466. return this.accept(program);
  1467. },
  1468. accept: function(node) {
  1469. return this[node.type](node);
  1470. },
  1471. program: function(program) {
  1472. var statements = program.statements;
  1473. for(var i=0, l=statements.length; i<l; i++) {
  1474. this.accept(statements[i]);
  1475. }
  1476. this.isSimple = l === 1;
  1477. this.depths.list = this.depths.list.sort(function(a, b) {
  1478. return a - b;
  1479. });
  1480. return this;
  1481. },
  1482. compileProgram: function(program) {
  1483. var result = new this.compiler().compile(program, this.options);
  1484. var guid = this.guid++, depth;
  1485. this.usePartial = this.usePartial || result.usePartial;
  1486. this.children[guid] = result;
  1487. for(var i=0, l=result.depths.list.length; i<l; i++) {
  1488. depth = result.depths.list[i];
  1489. if(depth < 2) { continue; }
  1490. else { this.addDepth(depth - 1); }
  1491. }
  1492. return guid;
  1493. },
  1494. block: function(block) {
  1495. var mustache = block.mustache,
  1496. program = block.program,
  1497. inverse = block.inverse;
  1498. if (program) {
  1499. program = this.compileProgram(program);
  1500. }
  1501. if (inverse) {
  1502. inverse = this.compileProgram(inverse);
  1503. }
  1504. var sexpr = mustache.sexpr;
  1505. var type = this.classifySexpr(sexpr);
  1506. if (type === "helper") {
  1507. this.helperSexpr(sexpr, program, inverse);
  1508. } else if (type === "simple") {
  1509. this.simpleSexpr(sexpr);
  1510. // now that the simple mustache is resolved, we need to
  1511. // evaluate it by executing `blockHelperMissing`
  1512. this.opcode('pushProgram', program);
  1513. this.opcode('pushProgram', inverse);
  1514. this.opcode('emptyHash');
  1515. this.opcode('blockValue', sexpr.id.original);
  1516. } else {
  1517. this.ambiguousSexpr(sexpr, program, inverse);
  1518. // now that the simple mustache is resolved, we need to
  1519. // evaluate it by executing `blockHelperMissing`
  1520. this.opcode('pushProgram', program);
  1521. this.opcode('pushProgram', inverse);
  1522. this.opcode('emptyHash');
  1523. this.opcode('ambiguousBlockValue');
  1524. }
  1525. this.opcode('append');
  1526. },
  1527. hash: function(hash) {
  1528. var pairs = hash.pairs, i, l;
  1529. this.opcode('pushHash');
  1530. for(i=0, l=pairs.length; i<l; i++) {
  1531. this.pushParam(pairs[i][1]);
  1532. }
  1533. while(i--) {
  1534. this.opcode('assignToHash', pairs[i][0]);
  1535. }
  1536. this.opcode('popHash');
  1537. },
  1538. partial: function(partial) {
  1539. var partialName = partial.partialName;
  1540. this.usePartial = true;
  1541. if (partial.hash) {
  1542. this.accept(partial.hash);
  1543. } else {
  1544. this.opcode('push', 'undefined');
  1545. }
  1546. if (partial.context) {
  1547. this.accept(partial.context);
  1548. } else {
  1549. this.opcode('getContext', 0);
  1550. this.opcode('pushContext');
  1551. }
  1552. this.opcode('invokePartial', partialName.name, partial.indent || '');
  1553. this.opcode('append');
  1554. },
  1555. content: function(content) {
  1556. if (content.string) {
  1557. this.opcode('appendContent', content.string);
  1558. }
  1559. },
  1560. mustache: function(mustache) {
  1561. this.sexpr(mustache.sexpr);
  1562. if(mustache.escaped && !this.options.noEscape) {
  1563. this.opcode('appendEscaped');
  1564. } else {
  1565. this.opcode('append');
  1566. }
  1567. },
  1568. ambiguousSexpr: function(sexpr, program, inverse) {
  1569. var id = sexpr.id,
  1570. name = id.parts[0],
  1571. isBlock = program != null || inverse != null;
  1572. this.opcode('getContext', id.depth);
  1573. this.opcode('pushProgram', program);
  1574. this.opcode('pushProgram', inverse);
  1575. this.ID(id);
  1576. this.opcode('invokeAmbiguous', name, isBlock);
  1577. },
  1578. simpleSexpr: function(sexpr) {
  1579. var id = sexpr.id;
  1580. if (id.type === 'DATA') {
  1581. this.DATA(id);
  1582. } else if (id.parts.length) {
  1583. this.ID(id);
  1584. } else {
  1585. // Simplified ID for `this`
  1586. this.addDepth(id.depth);
  1587. this.opcode('getContext', id.depth);
  1588. this.opcode('pushContext');
  1589. }
  1590. this.opcode('resolvePossibleLambda');
  1591. },
  1592. helperSexpr: function(sexpr, program, inverse) {
  1593. var params = this.setupFullMustacheParams(sexpr, program, inverse),
  1594. id = sexpr.id,
  1595. name = id.parts[0];
  1596. if (this.options.knownHelpers[name]) {
  1597. this.opcode('invokeKnownHelper', params.length, name);
  1598. } else if (this.options.knownHelpersOnly) {
  1599. throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
  1600. } else {
  1601. id.falsy = true;
  1602. this.ID(id);
  1603. this.opcode('invokeHelper', params.length, id.original, id.isSimple);
  1604. }
  1605. },
  1606. sexpr: function(sexpr) {
  1607. var type = this.classifySexpr(sexpr);
  1608. if (type === "simple") {
  1609. this.simpleSexpr(sexpr);
  1610. } else if (type === "helper") {
  1611. this.helperSexpr(sexpr);
  1612. } else {
  1613. this.ambiguousSexpr(sexpr);
  1614. }
  1615. },
  1616. ID: function(id) {
  1617. this.addDepth(id.depth);
  1618. this.opcode('getContext', id.depth);
  1619. var name = id.parts[0];
  1620. if (!name) {
  1621. // Context reference, i.e. `{{foo .}}` or `{{foo ..}}`
  1622. this.opcode('pushContext');
  1623. } else {
  1624. this.opcode('lookupOnContext', id.parts, id.falsy, id.isScoped);
  1625. }
  1626. },
  1627. DATA: function(data) {
  1628. this.options.data = true;
  1629. this.opcode('lookupData', data.id.depth, data.id.parts);
  1630. },
  1631. STRING: function(string) {
  1632. this.opcode('pushString', string.string);
  1633. },
  1634. NUMBER: function(number) {
  1635. this.opcode('pushLiteral', number.number);
  1636. },
  1637. BOOLEAN: function(bool) {
  1638. this.opcode('pushLiteral', bool.bool);
  1639. },
  1640. comment: function() {},
  1641. // HELPERS
  1642. opcode: function(name) {
  1643. this.opcodes.push({ opcode: name, args: slice.call(arguments, 1) });
  1644. },
  1645. addDepth: function(depth) {
  1646. if(depth === 0) { return; }
  1647. if(!this.depths[depth]) {
  1648. this.depths[depth] = true;
  1649. this.depths.list.push(depth);
  1650. }
  1651. },
  1652. classifySexpr: function(sexpr) {
  1653. var isHelper = sexpr.isHelper;
  1654. var isEligible = sexpr.eligibleHelper;
  1655. var options = this.options;
  1656. // if ambiguous, we can possibly resolve the ambiguity now
  1657. // An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc.
  1658. if (isEligible && !isHelper) {
  1659. var name = sexpr.id.parts[0];
  1660. if (options.knownHelpers[name]) {
  1661. isHelper = true;
  1662. } else if (options.knownHelpersOnly) {
  1663. isEligible = false;
  1664. }
  1665. }
  1666. if (isHelper) { return "helper"; }
  1667. else if (isEligible) { return "ambiguous"; }
  1668. else { return "simple"; }
  1669. },
  1670. pushParams: function(params) {
  1671. for(var i=0, l=params.length; i<l; i++) {
  1672. this.pushParam(params[i]);
  1673. }
  1674. },
  1675. pushParam: function(val) {
  1676. if (this.stringParams) {
  1677. if(val.depth) {
  1678. this.addDepth(val.depth);
  1679. }
  1680. this.opcode('getContext', val.depth || 0);
  1681. this.opcode('pushStringParam', val.stringModeValue, val.type);
  1682. if (val.type === 'sexpr') {
  1683. // Subexpressions get evaluated and passed in
  1684. // in string params mode.
  1685. this.sexpr(val);
  1686. }
  1687. } else {
  1688. if (this.trackIds) {
  1689. this.opcode('pushId', val.type, val.idName || val.stringModeValue);
  1690. }
  1691. this.accept(val);
  1692. }
  1693. },
  1694. setupFullMustacheParams: function(sexpr, program, inverse) {
  1695. var params = sexpr.params;
  1696. this.pushParams(params);
  1697. this.opcode('pushProgram', program);
  1698. this.opcode('pushProgram', inverse);
  1699. if (sexpr.hash) {
  1700. this.hash(sexpr.hash);
  1701. } else {
  1702. this.opcode('emptyHash');
  1703. }
  1704. return params;
  1705. }
  1706. };
  1707. function precompile(input, options, env) {
  1708. if (input == null || (typeof input !== 'string' && input.constructor !== env.AST.ProgramNode)) {
  1709. throw new Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
  1710. }
  1711. options = options || {};
  1712. if (!('data' in options)) {
  1713. options.data = true;
  1714. }
  1715. if (options.compat) {
  1716. options.useDepths = true;
  1717. }
  1718. var ast = env.parse(input);
  1719. var environment = new env.Compiler().compile(ast, options);
  1720. return new env.JavaScriptCompiler().compile(environment, options);
  1721. }
  1722. __exports__.precompile = precompile;function compile(input, options, env) {
  1723. if (input == null || (typeof input !== 'string' && input.constructor !== env.AST.ProgramNode)) {
  1724. throw new Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
  1725. }
  1726. options = options || {};
  1727. if (!('data' in options)) {
  1728. options.data = true;
  1729. }
  1730. if (options.compat) {
  1731. options.useDepths = true;
  1732. }
  1733. var compiled;
  1734. function compileInput() {
  1735. var ast = env.parse(input);
  1736. var environment = new env.Compiler().compile(ast, options);
  1737. var templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
  1738. return env.template(templateSpec);
  1739. }
  1740. // Template is only compiled on first use and cached after that point.
  1741. var ret = function(context, options) {
  1742. if (!compiled) {
  1743. compiled = compileInput();
  1744. }
  1745. return compiled.call(this, context, options);
  1746. };
  1747. ret._setup = function(options) {
  1748. if (!compiled) {
  1749. compiled = compileInput();
  1750. }
  1751. return compiled._setup(options);
  1752. };
  1753. ret._child = function(i, data, depths) {
  1754. if (!compiled) {
  1755. compiled = compileInput();
  1756. }
  1757. return compiled._child(i, data, depths);
  1758. };
  1759. return ret;
  1760. }
  1761. __exports__.compile = compile;function argEquals(a, b) {
  1762. if (a === b) {
  1763. return true;
  1764. }
  1765. if (isArray(a) && isArray(b) && a.length === b.length) {
  1766. for (var i = 0; i < a.length; i++) {
  1767. if (!argEquals(a[i], b[i])) {
  1768. return false;
  1769. }
  1770. }
  1771. return true;
  1772. }
  1773. }
  1774. return __exports__;
  1775. })(__module5__, __module3__);
  1776. // handlebars/compiler/javascript-compiler.js
  1777. var __module12__ = (function(__dependency1__, __dependency2__) {
  1778. "use strict";
  1779. var __exports__;
  1780. var COMPILER_REVISION = __dependency1__.COMPILER_REVISION;
  1781. var REVISION_CHANGES = __dependency1__.REVISION_CHANGES;
  1782. var Exception = __dependency2__;
  1783. function Literal(value) {
  1784. this.value = value;
  1785. }
  1786. function JavaScriptCompiler() {}
  1787. JavaScriptCompiler.prototype = {
  1788. // PUBLIC API: You can override these methods in a subclass to provide
  1789. // alternative compiled forms for name lookup and buffering semantics
  1790. nameLookup: function(parent, name /* , type*/) {
  1791. if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
  1792. return parent + "." + name;
  1793. } else {
  1794. return parent + "['" + name + "']";
  1795. }
  1796. },
  1797. depthedLookup: function(name) {
  1798. this.aliases.lookup = 'this.lookup';
  1799. return 'lookup(depths, "' + name + '")';
  1800. },
  1801. compilerInfo: function() {
  1802. var revision = COMPILER_REVISION,
  1803. versions = REVISION_CHANGES[revision];
  1804. return [revision, versions];
  1805. },
  1806. appendToBuffer: function(string) {
  1807. if (this.environment.isSimple) {
  1808. return "return " + string + ";";
  1809. } else {
  1810. return {
  1811. appendToBuffer: true,
  1812. content: string,
  1813. toString: function() { return "buffer += " + string + ";"; }
  1814. };
  1815. }
  1816. },
  1817. initializeBuffer: function() {
  1818. return this.quotedString("");
  1819. },
  1820. namespace: "Handlebars",
  1821. // END PUBLIC API
  1822. compile: function(environment, options, context, asObject) {
  1823. this.environment = environment;
  1824. this.options = options;
  1825. this.stringParams = this.options.stringParams;
  1826. this.trackIds = this.options.trackIds;
  1827. this.precompile = !asObject;
  1828. this.name = this.environment.name;
  1829. this.isChild = !!context;
  1830. this.context = context || {
  1831. programs: [],
  1832. environments: []
  1833. };
  1834. this.preamble();
  1835. this.stackSlot = 0;
  1836. this.stackVars = [];
  1837. this.aliases = {};
  1838. this.registers = { list: [] };
  1839. this.hashes = [];
  1840. this.compileStack = [];
  1841. this.inlineStack = [];
  1842. this.compileChildren(environment, options);
  1843. this.useDepths = this.useDepths || environment.depths.list.length || this.options.compat;
  1844. var opcodes = environment.opcodes,
  1845. opcode,
  1846. i,
  1847. l;
  1848. for (i = 0, l = opcodes.length; i < l; i++) {
  1849. opcode = opcodes[i];
  1850. this[opcode.opcode].apply(this, opcode.args);
  1851. }
  1852. // Flush any trailing content that might be pending.
  1853. this.pushSource('');
  1854. /* istanbul ignore next */
  1855. if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
  1856. throw new Exception('Compile completed with content left on stack');
  1857. }
  1858. var fn = this.createFunctionContext(asObject);
  1859. if (!this.isChild) {
  1860. var ret = {
  1861. compiler: this.compilerInfo(),
  1862. main: fn
  1863. };
  1864. var programs = this.context.programs;
  1865. for (i = 0, l = programs.length; i < l; i++) {
  1866. if (programs[i]) {
  1867. ret[i] = programs[i];
  1868. }
  1869. }
  1870. if (this.environment.usePartial) {
  1871. ret.usePartial = true;
  1872. }
  1873. if (this.options.data) {
  1874. ret.useData = true;
  1875. }
  1876. if (this.useDepths) {
  1877. ret.useDepths = true;
  1878. }
  1879. if (this.options.compat) {
  1880. ret.compat = true;
  1881. }
  1882. if (!asObject) {
  1883. ret.compiler = JSON.stringify(ret.compiler);
  1884. ret = this.objectLiteral(ret);
  1885. }
  1886. return ret;
  1887. } else {
  1888. return fn;
  1889. }
  1890. },
  1891. preamble: function() {
  1892. // track the last context pushed into place to allow skipping the
  1893. // getContext opcode when it would be a noop
  1894. this.lastContext = 0;
  1895. this.source = [];
  1896. },
  1897. createFunctionContext: function(asObject) {
  1898. var varDeclarations = '';
  1899. var locals = this.stackVars.concat(this.registers.list);
  1900. if(locals.length > 0) {
  1901. varDeclarations += ", " + locals.join(", ");
  1902. }
  1903. // Generate minimizer alias mappings
  1904. for (var alias in this.aliases) {
  1905. if (this.aliases.hasOwnProperty(alias)) {
  1906. varDeclarations += ', ' + alias + '=' + this.aliases[alias];
  1907. }
  1908. }
  1909. var params = ["depth0", "helpers", "partials", "data"];
  1910. if (this.useDepths) {
  1911. params.push('depths');
  1912. }
  1913. // Perform a second pass over the output to merge content when possible
  1914. var source = this.mergeSource(varDeclarations);
  1915. if (asObject) {
  1916. params.push(source);
  1917. return Function.apply(this, params);
  1918. } else {
  1919. return 'function(' + params.join(',') + ') {\n ' + source + '}';
  1920. }
  1921. },
  1922. mergeSource: function(varDeclarations) {
  1923. var source = '',
  1924. buffer,
  1925. appendOnly = !this.forceBuffer,
  1926. appendFirst;
  1927. for (var i = 0, len = this.source.length; i < len; i++) {
  1928. var line = this.source[i];
  1929. if (line.appendToBuffer) {
  1930. if (buffer) {
  1931. buffer = buffer + '\n + ' + line.content;
  1932. } else {
  1933. buffer = line.content;
  1934. }
  1935. } else {
  1936. if (buffer) {
  1937. if (!source) {
  1938. appendFirst = true;
  1939. source = buffer + ';\n ';
  1940. } else {
  1941. source += 'buffer += ' + buffer + ';\n ';
  1942. }
  1943. buffer = undefined;
  1944. }
  1945. source += line + '\n ';
  1946. if (!this.environment.isSimple) {
  1947. appendOnly = false;
  1948. }
  1949. }
  1950. }
  1951. if (appendOnly) {
  1952. if (buffer || !source) {
  1953. source += 'return ' + (buffer || '""') + ';\n';
  1954. }
  1955. } else {
  1956. varDeclarations += ", buffer = " + (appendFirst ? '' : this.initializeBuffer());
  1957. if (buffer) {
  1958. source += 'return buffer + ' + buffer + ';\n';
  1959. } else {
  1960. source += 'return buffer;\n';
  1961. }
  1962. }
  1963. if (varDeclarations) {
  1964. source = 'var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n ') + source;
  1965. }
  1966. return source;
  1967. },
  1968. // [blockValue]
  1969. //
  1970. // On stack, before: hash, inverse, program, value
  1971. // On stack, after: return value of blockHelperMissing
  1972. //
  1973. // The purpose of this opcode is to take a block of the form
  1974. // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and
  1975. // replace it on the stack with the result of properly
  1976. // invoking blockHelperMissing.
  1977. blockValue: function(name) {
  1978. this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
  1979. var params = [this.contextName(0)];
  1980. this.setupParams(name, 0, params);
  1981. var blockName = this.popStack();
  1982. params.splice(1, 0, blockName);
  1983. this.push('blockHelperMissing.call(' + params.join(', ') + ')');
  1984. },
  1985. // [ambiguousBlockValue]
  1986. //
  1987. // On stack, before: hash, inverse, program, value
  1988. // Compiler value, before: lastHelper=value of last found helper, if any
  1989. // On stack, after, if no lastHelper: same as [blockValue]
  1990. // On stack, after, if lastHelper: value
  1991. ambiguousBlockValue: function() {
  1992. this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
  1993. // We're being a bit cheeky and reusing the options value from the prior exec
  1994. var params = [this.contextName(0)];
  1995. this.setupParams('', 0, params, true);
  1996. this.flushInline();
  1997. var current = this.topStack();
  1998. params.splice(1, 0, current);
  1999. this.pushSource("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }");
  2000. },
  2001. // [appendContent]
  2002. //
  2003. // On stack, before: ...
  2004. // On stack, after: ...
  2005. //
  2006. // Appends the string value of `content` to the current buffer
  2007. appendContent: function(content) {
  2008. if (this.pendingContent) {
  2009. content = this.pendingContent + content;
  2010. }
  2011. this.pendingContent = content;
  2012. },
  2013. // [append]
  2014. //
  2015. // On stack, before: value, ...
  2016. // On stack, after: ...
  2017. //
  2018. // Coerces `value` to a String and appends it to the current buffer.
  2019. //
  2020. // If `value` is truthy, or 0, it is coerced into a string and appended
  2021. // Otherwise, the empty string is appended
  2022. append: function() {
  2023. // Force anything that is inlined onto the stack so we don't have duplication
  2024. // when we examine local
  2025. this.flushInline();
  2026. var local = this.popStack();
  2027. this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
  2028. if (this.environment.isSimple) {
  2029. this.pushSource("else { " + this.appendToBuffer("''") + " }");
  2030. }
  2031. },
  2032. // [appendEscaped]
  2033. //
  2034. // On stack, before: value, ...
  2035. // On stack, after: ...
  2036. //
  2037. // Escape `value` and append it to the buffer
  2038. appendEscaped: function() {
  2039. this.aliases.escapeExpression = 'this.escapeExpression';
  2040. this.pushSource(this.appendToBuffer("escapeExpression(" + this.popStack() + ")"));
  2041. },
  2042. // [getContext]
  2043. //
  2044. // On stack, before: ...
  2045. // On stack, after: ...
  2046. // Compiler value, after: lastContext=depth
  2047. //
  2048. // Set the value of the `lastContext` compiler value to the depth
  2049. getContext: function(depth) {
  2050. this.lastContext = depth;
  2051. },
  2052. // [pushContext]
  2053. //
  2054. // On stack, before: ...
  2055. // On stack, after: currentContext, ...
  2056. //
  2057. // Pushes the value of the current context onto the stack.
  2058. pushContext: function() {
  2059. this.pushStackLiteral(this.contextName(this.lastContext));
  2060. },
  2061. // [lookupOnContext]
  2062. //
  2063. // On stack, before: ...
  2064. // On stack, after: currentContext[name], ...
  2065. //
  2066. // Looks up the value of `name` on the current context and pushes
  2067. // it onto the stack.
  2068. lookupOnContext: function(parts, falsy, scoped) {
  2069. /*jshint -W083 */
  2070. var i = 0,
  2071. len = parts.length;
  2072. if (!scoped && this.options.compat && !this.lastContext) {
  2073. // The depthed query is expected to handle the undefined logic for the root level that
  2074. // is implemented below, so we evaluate that directly in compat mode
  2075. this.push(this.depthedLookup(parts[i++]));
  2076. } else {
  2077. this.pushContext();
  2078. }
  2079. for (; i < len; i++) {
  2080. this.replaceStack(function(current) {
  2081. var lookup = this.nameLookup(current, parts[i], 'context');
  2082. // We want to ensure that zero and false are handled properly if the context (falsy flag)
  2083. // needs to have the special handling for these values.
  2084. if (!falsy) {
  2085. return ' != null ? ' + lookup + ' : ' + current;
  2086. } else {
  2087. // Otherwise we can use generic falsy handling
  2088. return ' && ' + lookup;
  2089. }
  2090. });
  2091. }
  2092. },
  2093. // [lookupData]
  2094. //
  2095. // On stack, before: ...
  2096. // On stack, after: data, ...
  2097. //
  2098. // Push the data lookup operator
  2099. lookupData: function(depth, parts) {
  2100. /*jshint -W083 */
  2101. if (!depth) {
  2102. this.pushStackLiteral('data');
  2103. } else {
  2104. this.pushStackLiteral('this.data(data, ' + depth + ')');
  2105. }
  2106. var len = parts.length;
  2107. for (var i = 0; i < len; i++) {
  2108. this.replaceStack(function(current) {
  2109. return ' && ' + this.nameLookup(current, parts[i], 'data');
  2110. });
  2111. }
  2112. },
  2113. // [resolvePossibleLambda]
  2114. //
  2115. // On stack, before: value, ...
  2116. // On stack, after: resolved value, ...
  2117. //
  2118. // If the `value` is a lambda, replace it on the stack by
  2119. // the return value of the lambda
  2120. resolvePossibleLambda: function() {
  2121. this.aliases.lambda = 'this.lambda';
  2122. this.push('lambda(' + this.popStack() + ', ' + this.contextName(0) + ')');
  2123. },
  2124. // [pushStringParam]
  2125. //
  2126. // On stack, before: ...
  2127. // On stack, after: string, currentContext, ...
  2128. //
  2129. // This opcode is designed for use in string mode, which
  2130. // provides the string value of a parameter along with its
  2131. // depth rather than resolving it immediately.
  2132. pushStringParam: function(string, type) {
  2133. this.pushContext();
  2134. this.pushString(type);
  2135. // If it's a subexpression, the string result
  2136. // will be pushed after this opcode.
  2137. if (type !== 'sexpr') {
  2138. if (typeof string === 'string') {
  2139. this.pushString(string);
  2140. } else {
  2141. this.pushStackLiteral(string);
  2142. }
  2143. }
  2144. },
  2145. emptyHash: function() {
  2146. this.pushStackLiteral('{}');
  2147. if (this.trackIds) {
  2148. this.push('{}'); // hashIds
  2149. }
  2150. if (this.stringParams) {
  2151. this.push('{}'); // hashContexts
  2152. this.push('{}'); // hashTypes
  2153. }
  2154. },
  2155. pushHash: function() {
  2156. if (this.hash) {
  2157. this.hashes.push(this.hash);
  2158. }
  2159. this.hash = {values: [], types: [], contexts: [], ids: []};
  2160. },
  2161. popHash: function() {
  2162. var hash = this.hash;
  2163. this.hash = this.hashes.pop();
  2164. if (this.trackIds) {
  2165. this.push('{' + hash.ids.join(',') + '}');
  2166. }
  2167. if (this.stringParams) {
  2168. this.push('{' + hash.contexts.join(',') + '}');
  2169. this.push('{' + hash.types.join(',') + '}');
  2170. }
  2171. this.push('{\n ' + hash.values.join(',\n ') + '\n }');
  2172. },
  2173. // [pushString]
  2174. //
  2175. // On stack, before: ...
  2176. // On stack, after: quotedString(string), ...
  2177. //
  2178. // Push a quoted version of `string` onto the stack
  2179. pushString: function(string) {
  2180. this.pushStackLiteral(this.quotedString(string));
  2181. },
  2182. // [push]
  2183. //
  2184. // On stack, before: ...
  2185. // On stack, after: expr, ...
  2186. //
  2187. // Push an expression onto the stack
  2188. push: function(expr) {
  2189. this.inlineStack.push(expr);
  2190. return expr;
  2191. },
  2192. // [pushLiteral]
  2193. //
  2194. // On stack, before: ...
  2195. // On stack, after: value, ...
  2196. //
  2197. // Pushes a value onto the stack. This operation prevents
  2198. // the compiler from creating a temporary variable to hold
  2199. // it.
  2200. pushLiteral: function(value) {
  2201. this.pushStackLiteral(value);
  2202. },
  2203. // [pushProgram]
  2204. //
  2205. // On stack, before: ...
  2206. // On stack, after: program(guid), ...
  2207. //
  2208. // Push a program expression onto the stack. This takes
  2209. // a compile-time guid and converts it into a runtime-accessible
  2210. // expression.
  2211. pushProgram: function(guid) {
  2212. if (guid != null) {
  2213. this.pushStackLiteral(this.programExpression(guid));
  2214. } else {
  2215. this.pushStackLiteral(null);
  2216. }
  2217. },
  2218. // [invokeHelper]
  2219. //
  2220. // On stack, before: hash, inverse, program, params..., ...
  2221. // On stack, after: result of helper invocation
  2222. //
  2223. // Pops off the helper's parameters, invokes the helper,
  2224. // and pushes the helper's return value onto the stack.
  2225. //
  2226. // If the helper is not found, `helperMissing` is called.
  2227. invokeHelper: function(paramSize, name, isSimple) {
  2228. this.aliases.helperMissing = 'helpers.helperMissing';
  2229. var nonHelper = this.popStack();
  2230. var helper = this.setupHelper(paramSize, name);
  2231. var lookup = (isSimple ? helper.name + ' || ' : '') + nonHelper + ' || helperMissing';
  2232. this.push('((' + lookup + ').call(' + helper.callParams + '))');
  2233. },
  2234. // [invokeKnownHelper]
  2235. //
  2236. // On stack, before: hash, inverse, program, params..., ...
  2237. // On stack, after: result of helper invocation
  2238. //
  2239. // This operation is used when the helper is known to exist,
  2240. // so a `helperMissing` fallback is not required.
  2241. invokeKnownHelper: function(paramSize, name) {
  2242. var helper = this.setupHelper(paramSize, name);
  2243. this.push(helper.name + ".call(" + helper.callParams + ")");
  2244. },
  2245. // [invokeAmbiguous]
  2246. //
  2247. // On stack, before: hash, inverse, program, params..., ...
  2248. // On stack, after: result of disambiguation
  2249. //
  2250. // This operation is used when an expression like `{{foo}}`
  2251. // is provided, but we don't know at compile-time whether it
  2252. // is a helper or a path.
  2253. //
  2254. // This operation emits more code than the other options,
  2255. // and can be avoided by passing the `knownHelpers` and
  2256. // `knownHelpersOnly` flags at compile-time.
  2257. invokeAmbiguous: function(name, helperCall) {
  2258. this.aliases.functionType = '"function"';
  2259. this.aliases.helperMissing = 'helpers.helperMissing';
  2260. this.useRegister('helper');
  2261. var nonHelper = this.popStack();
  2262. this.emptyHash();
  2263. var helper = this.setupHelper(0, name, helperCall);
  2264. var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
  2265. this.push(
  2266. '((helper = (helper = ' + helperName + ' || ' + nonHelper + ') != null ? helper : helperMissing'
  2267. + (helper.paramsInit ? '),(' + helper.paramsInit : '') + '),'
  2268. + '(typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper))');
  2269. },
  2270. // [invokePartial]
  2271. //
  2272. // On stack, before: context, ...
  2273. // On stack after: result of partial invocation
  2274. //
  2275. // This operation pops off a context, invokes a partial with that context,
  2276. // and pushes the result of the invocation back.
  2277. invokePartial: function(name, indent) {
  2278. var params = [this.nameLookup('partials', name, 'partial'), "'" + indent + "'", "'" + name + "'", this.popStack(), this.popStack(), "helpers", "partials"];
  2279. if (this.options.data) {
  2280. params.push("data");
  2281. } else if (this.options.compat) {
  2282. params.push('undefined');
  2283. }
  2284. if (this.options.compat) {
  2285. params.push('depths');
  2286. }
  2287. this.push("this.invokePartial(" + params.join(", ") + ")");
  2288. },
  2289. // [assignToHash]
  2290. //
  2291. // On stack, before: value, ..., hash, ...
  2292. // On stack, after: ..., hash, ...
  2293. //
  2294. // Pops a value off the stack and assigns it to the current hash
  2295. assignToHash: function(key) {
  2296. var value = this.popStack(),
  2297. context,
  2298. type,
  2299. id;
  2300. if (this.trackIds) {
  2301. id = this.popStack();
  2302. }
  2303. if (this.stringParams) {
  2304. type = this.popStack();
  2305. context = this.popStack();
  2306. }
  2307. var hash = this.hash;
  2308. if (context) {
  2309. hash.contexts.push("'" + key + "': " + context);
  2310. }
  2311. if (type) {
  2312. hash.types.push("'" + key + "': " + type);
  2313. }
  2314. if (id) {
  2315. hash.ids.push("'" + key + "': " + id);
  2316. }
  2317. hash.values.push("'" + key + "': (" + value + ")");
  2318. },
  2319. pushId: function(type, name) {
  2320. if (type === 'ID' || type === 'DATA') {
  2321. this.pushString(name);
  2322. } else if (type === 'sexpr') {
  2323. this.pushStackLiteral('true');
  2324. } else {
  2325. this.pushStackLiteral('null');
  2326. }
  2327. },
  2328. // HELPERS
  2329. compiler: JavaScriptCompiler,
  2330. compileChildren: function(environment, options) {
  2331. var children = environment.children, child, compiler;
  2332. for(var i=0, l=children.length; i<l; i++) {
  2333. child = children[i];
  2334. compiler = new this.compiler();
  2335. var index = this.matchExistingProgram(child);
  2336. if (index == null) {
  2337. this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
  2338. index = this.context.programs.length;
  2339. child.index = index;
  2340. child.name = 'program' + index;
  2341. this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile);
  2342. this.context.environments[index] = child;
  2343. this.useDepths = this.useDepths || compiler.useDepths;
  2344. } else {
  2345. child.index = index;
  2346. child.name = 'program' + index;
  2347. }
  2348. }
  2349. },
  2350. matchExistingProgram: function(child) {
  2351. for (var i = 0, len = this.context.environments.length; i < len; i++) {
  2352. var environment = this.context.environments[i];
  2353. if (environment && environment.equals(child)) {
  2354. return i;
  2355. }
  2356. }
  2357. },
  2358. programExpression: function(guid) {
  2359. var child = this.environment.children[guid],
  2360. depths = child.depths.list,
  2361. useDepths = this.useDepths,
  2362. depth;
  2363. var programParams = [child.index, 'data'];
  2364. if (useDepths) {
  2365. programParams.push('depths');
  2366. }
  2367. return 'this.program(' + programParams.join(', ') + ')';
  2368. },
  2369. useRegister: function(name) {
  2370. if(!this.registers[name]) {
  2371. this.registers[name] = true;
  2372. this.registers.list.push(name);
  2373. }
  2374. },
  2375. pushStackLiteral: function(item) {
  2376. return this.push(new Literal(item));
  2377. },
  2378. pushSource: function(source) {
  2379. if (this.pendingContent) {
  2380. this.source.push(this.appendToBuffer(this.quotedString(this.pendingContent)));
  2381. this.pendingContent = undefined;
  2382. }
  2383. if (source) {
  2384. this.source.push(source);
  2385. }
  2386. },
  2387. pushStack: function(item) {
  2388. this.flushInline();
  2389. var stack = this.incrStack();
  2390. this.pushSource(stack + " = " + item + ";");
  2391. this.compileStack.push(stack);
  2392. return stack;
  2393. },
  2394. replaceStack: function(callback) {
  2395. var prefix = '',
  2396. inline = this.isInline(),
  2397. stack,
  2398. createdStack,
  2399. usedLiteral;
  2400. /* istanbul ignore next */
  2401. if (!this.isInline()) {
  2402. throw new Exception('replaceStack on non-inline');
  2403. }
  2404. // We want to merge the inline statement into the replacement statement via ','
  2405. var top = this.popStack(true);
  2406. if (top instanceof Literal) {
  2407. // Literals do not need to be inlined
  2408. prefix = stack = top.value;
  2409. usedLiteral = true;
  2410. } else {
  2411. // Get or create the current stack name for use by the inline
  2412. createdStack = !this.stackSlot;
  2413. var name = !createdStack ? this.topStackName() : this.incrStack();
  2414. prefix = '(' + this.push(name) + ' = ' + top + ')';
  2415. stack = this.topStack();
  2416. }
  2417. var item = callback.call(this, stack);
  2418. if (!usedLiteral) {
  2419. this.popStack();
  2420. }
  2421. if (createdStack) {
  2422. this.stackSlot--;
  2423. }
  2424. this.push('(' + prefix + item + ')');
  2425. },
  2426. incrStack: function() {
  2427. this.stackSlot++;
  2428. if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
  2429. return this.topStackName();
  2430. },
  2431. topStackName: function() {
  2432. return "stack" + this.stackSlot;
  2433. },
  2434. flushInline: function() {
  2435. var inlineStack = this.inlineStack;
  2436. if (inlineStack.length) {
  2437. this.inlineStack = [];
  2438. for (var i = 0, len = inlineStack.length; i < len; i++) {
  2439. var entry = inlineStack[i];
  2440. if (entry instanceof Literal) {
  2441. this.compileStack.push(entry);
  2442. } else {
  2443. this.pushStack(entry);
  2444. }
  2445. }
  2446. }
  2447. },
  2448. isInline: function() {
  2449. return this.inlineStack.length;
  2450. },
  2451. popStack: function(wrapped) {
  2452. var inline = this.isInline(),
  2453. item = (inline ? this.inlineStack : this.compileStack).pop();
  2454. if (!wrapped && (item instanceof Literal)) {
  2455. return item.value;
  2456. } else {
  2457. if (!inline) {
  2458. /* istanbul ignore next */
  2459. if (!this.stackSlot) {
  2460. throw new Exception('Invalid stack pop');
  2461. }
  2462. this.stackSlot--;
  2463. }
  2464. return item;
  2465. }
  2466. },
  2467. topStack: function() {
  2468. var stack = (this.isInline() ? this.inlineStack : this.compileStack),
  2469. item = stack[stack.length - 1];
  2470. if (item instanceof Literal) {
  2471. return item.value;
  2472. } else {
  2473. return item;
  2474. }
  2475. },
  2476. contextName: function(context) {
  2477. if (this.useDepths && context) {
  2478. return 'depths[' + context + ']';
  2479. } else {
  2480. return 'depth' + context;
  2481. }
  2482. },
  2483. quotedString: function(str) {
  2484. return '"' + str
  2485. .replace(/\\/g, '\\\\')
  2486. .replace(/"/g, '\\"')
  2487. .replace(/\n/g, '\\n')
  2488. .replace(/\r/g, '\\r')
  2489. .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
  2490. .replace(/\u2029/g, '\\u2029') + '"';
  2491. },
  2492. objectLiteral: function(obj) {
  2493. var pairs = [];
  2494. for (var key in obj) {
  2495. if (obj.hasOwnProperty(key)) {
  2496. pairs.push(this.quotedString(key) + ':' + obj[key]);
  2497. }
  2498. }
  2499. return '{' + pairs.join(',') + '}';
  2500. },
  2501. setupHelper: function(paramSize, name, blockHelper) {
  2502. var params = [],
  2503. paramsInit = this.setupParams(name, paramSize, params, blockHelper);
  2504. var foundHelper = this.nameLookup('helpers', name, 'helper');
  2505. return {
  2506. params: params,
  2507. paramsInit: paramsInit,
  2508. name: foundHelper,
  2509. callParams: [this.contextName(0)].concat(params).join(", ")
  2510. };
  2511. },
  2512. setupOptions: function(helper, paramSize, params) {
  2513. var options = {}, contexts = [], types = [], ids = [], param, inverse, program;
  2514. options.name = this.quotedString(helper);
  2515. options.hash = this.popStack();
  2516. if (this.trackIds) {
  2517. options.hashIds = this.popStack();
  2518. }
  2519. if (this.stringParams) {
  2520. options.hashTypes = this.popStack();
  2521. options.hashContexts = this.popStack();
  2522. }
  2523. inverse = this.popStack();
  2524. program = this.popStack();
  2525. // Avoid setting fn and inverse if neither are set. This allows
  2526. // helpers to do a check for `if (options.fn)`
  2527. if (program || inverse) {
  2528. if (!program) {
  2529. program = 'this.noop';
  2530. }
  2531. if (!inverse) {
  2532. inverse = 'this.noop';
  2533. }
  2534. options.fn = program;
  2535. options.inverse = inverse;
  2536. }
  2537. // The parameters go on to the stack in order (making sure that they are evaluated in order)
  2538. // so we need to pop them off the stack in reverse order
  2539. var i = paramSize;
  2540. while (i--) {
  2541. param = this.popStack();
  2542. params[i] = param;
  2543. if (this.trackIds) {
  2544. ids[i] = this.popStack();
  2545. }
  2546. if (this.stringParams) {
  2547. types[i] = this.popStack();
  2548. contexts[i] = this.popStack();
  2549. }
  2550. }
  2551. if (this.trackIds) {
  2552. options.ids = "[" + ids.join(",") + "]";
  2553. }
  2554. if (this.stringParams) {
  2555. options.types = "[" + types.join(",") + "]";
  2556. options.contexts = "[" + contexts.join(",") + "]";
  2557. }
  2558. if (this.options.data) {
  2559. options.data = "data";
  2560. }
  2561. return options;
  2562. },
  2563. // the params and contexts arguments are passed in arrays
  2564. // to fill in
  2565. setupParams: function(helperName, paramSize, params, useRegister) {
  2566. var options = this.objectLiteral(this.setupOptions(helperName, paramSize, params));
  2567. if (useRegister) {
  2568. this.useRegister('options');
  2569. params.push('options');
  2570. return 'options=' + options;
  2571. } else {
  2572. params.push(options);
  2573. return '';
  2574. }
  2575. }
  2576. };
  2577. var reservedWords = (
  2578. "break else new var" +
  2579. " case finally return void" +
  2580. " catch for switch while" +
  2581. " continue function this with" +
  2582. " default if throw" +
  2583. " delete in try" +
  2584. " do instanceof typeof" +
  2585. " abstract enum int short" +
  2586. " boolean export interface static" +
  2587. " byte extends long super" +
  2588. " char final native synchronized" +
  2589. " class float package throws" +
  2590. " const goto private transient" +
  2591. " debugger implements protected volatile" +
  2592. " double import public let yield"
  2593. ).split(" ");
  2594. var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
  2595. for(var i=0, l=reservedWords.length; i<l; i++) {
  2596. compilerWords[reservedWords[i]] = true;
  2597. }
  2598. JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
  2599. return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
  2600. };
  2601. __exports__ = JavaScriptCompiler;
  2602. return __exports__;
  2603. })(__module2__, __module5__);
  2604. // handlebars.js
  2605. var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
  2606. "use strict";
  2607. var __exports__;
  2608. /*globals Handlebars: true */
  2609. var Handlebars = __dependency1__;
  2610. // Compiler imports
  2611. var AST = __dependency2__;
  2612. var Parser = __dependency3__.parser;
  2613. var parse = __dependency3__.parse;
  2614. var Compiler = __dependency4__.Compiler;
  2615. var compile = __dependency4__.compile;
  2616. var precompile = __dependency4__.precompile;
  2617. var JavaScriptCompiler = __dependency5__;
  2618. var _create = Handlebars.create;
  2619. var create = function() {
  2620. var hb = _create();
  2621. hb.compile = function(input, options) {
  2622. return compile(input, options, hb);
  2623. };
  2624. hb.precompile = function (input, options) {
  2625. return precompile(input, options, hb);
  2626. };
  2627. hb.AST = AST;
  2628. hb.Compiler = Compiler;
  2629. hb.JavaScriptCompiler = JavaScriptCompiler;
  2630. hb.Parser = Parser;
  2631. hb.parse = parse;
  2632. return hb;
  2633. };
  2634. Handlebars = create();
  2635. Handlebars.create = create;
  2636. Handlebars['default'] = Handlebars;
  2637. __exports__ = Handlebars;
  2638. return __exports__;
  2639. })(__module1__, __module7__, __module8__, __module11__, __module12__);
  2640. return __module0__;
  2641. }));