Produced by Araxis Merge on 2/1/2017 2:57:59 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM Portal\trunk\BTSSSPortal\js | handlebars.js | Tue Dec 20 19:50:52 2016 UTC |
| 2 | Wed Feb 1 19:57:59 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 2746 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /*! | |||||
| 2 | ||||||
| 3 | handlebar s v1.3.0 | |||||
| 4 | ||||||
| 5 | Copyright (C) 2011 b y Yehuda K atz | |||||
| 6 | ||||||
| 7 | Permission is hereby granted, free of ch arge, to a ny person obtaining a copy | |||||
| 8 | of this so ftware and associate d document ation file s (the "So ftware"), to deal | |||||
| 9 | in the Sof tware with out restri ction, inc luding wit hout limit ation the rights | |||||
| 10 | to use, co py, modify , merge, p ublish, di stribute, sublicense , and/or s ell | |||||
| 11 | copies of the Softwa re, and to permit pe rsons to w hom the So ftware is | |||||
| 12 | furnished to do so, subject to the follo wing condi tions: | |||||
| 13 | ||||||
| 14 | The above copyright notice and this perm ission not ice shall be include d in | |||||
| 15 | all copies or substa ntial port ions of th e Software . | |||||
| 16 | ||||||
| 17 | THE SOFTWA RE IS PROV IDED "AS I S", WITHOU T WARRANTY OF ANY KI ND, EXPRES S OR | |||||
| 18 | IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E WARRANTI ES OF MERC HANTABILIT Y, | |||||
| 19 | FITNESS FO R A PARTIC ULAR PURPO SE AND NON INFRINGEME NT. IN NO EVENT SHAL L THE | |||||
| 20 | AUTHORS OR COPYRIGHT HOLDERS B E LIABLE F OR ANY CLA IM, DAMAGE S OR OTHER | |||||
| 21 | LIABILITY, WHETHER I N AN ACTIO N OF CONTR ACT, TORT OR OTHERWI SE, ARISIN G FROM, | |||||
| 22 | OUT OF OR IN CONNECT ION WITH T HE SOFTWAR E OR THE U SE OR OTHE R DEALINGS IN | |||||
| 23 | THE SOFTWA RE. | |||||
| 24 | ||||||
| 25 | @license | |||||
| 26 | */ | |||||
| 27 | /* exporte d Handleba rs */ | |||||
| 28 | var Handle bars = (fu nction() { | |||||
| 29 | // handleb ars/safe-s tring.js | |||||
| 30 | var __modu le4__ = (f unction() { | |||||
| 31 | "use str ict"; | |||||
| 32 | var __ex ports__; | |||||
| 33 | // Build out our b asic SafeS tring type | |||||
| 34 | function SafeStrin g(string) { | |||||
| 35 | this.s tring = st ring; | |||||
| 36 | } | |||||
| 37 | ||||||
| 38 | SafeStri ng.prototy pe.toStrin g = functi on() { | |||||
| 39 | return "" + this .string; | |||||
| 40 | }; | |||||
| 41 | ||||||
| 42 | __export s__ = Safe String; | |||||
| 43 | return _ _exports__ ; | |||||
| 44 | })(); | |||||
| 45 | ||||||
| 46 | // handleb ars/utils. js | |||||
| 47 | var __modu le3__ = (f unction(__ dependency 1__) { | |||||
| 48 | "use str ict"; | |||||
| 49 | var __ex ports__ = {}; | |||||
| 50 | /*jshint -W004 */ | |||||
| 51 | var Safe String = _ _dependenc y1__; | |||||
| 52 | ||||||
| 53 | var esca pe = { | |||||
| 54 | "&": " &", | |||||
| 55 | "<": " <", | |||||
| 56 | ">": " >", | |||||
| 57 | '"': " "", | |||||
| 58 | "'": " '", | |||||
| 59 | "`": " `" | |||||
| 60 | }; | |||||
| 61 | ||||||
| 62 | var badC hars = /[& <>"'`]/g; | |||||
| 63 | var poss ible = /[& <>"'`]/; | |||||
| 64 | ||||||
| 65 | function escapeCha r(chr) { | |||||
| 66 | return escape[ch r] || "&am p;"; | |||||
| 67 | } | |||||
| 68 | ||||||
| 69 | function extend(ob j, value) { | |||||
| 70 | for(va r key in v alue) { | |||||
| 71 | if(O bject.prot otype.hasO wnProperty .call(valu e, key)) { | |||||
| 72 | ob j[key] = v alue[key]; | |||||
| 73 | } | |||||
| 74 | } | |||||
| 75 | } | |||||
| 76 | ||||||
| 77 | __export s__.extend = extend; var toStri ng = Objec t.prototyp e.toString ; | |||||
| 78 | __export s__.toStri ng = toStr ing; | |||||
| 79 | // Sourc ed from lo dash | |||||
| 80 | // https ://github. com/bestie js/lodash/ blob/maste r/LICENSE. txt | |||||
| 81 | var isFu nction = f unction(va lue) { | |||||
| 82 | return typeof va lue === 'f unction'; | |||||
| 83 | }; | |||||
| 84 | // fallb ack for ol der versio ns of Chro me and Saf ari | |||||
| 85 | if (isFu nction(/x/ )) { | |||||
| 86 | isFunc tion = fun ction(valu e) { | |||||
| 87 | retu rn typeof value === 'function' && toStri ng.call(va lue) === ' [object Fu nction]'; | |||||
| 88 | }; | |||||
| 89 | } | |||||
| 90 | var isFu nction; | |||||
| 91 | __export s__.isFunc tion = isF unction; | |||||
| 92 | var isAr ray = Arra y.isArray || functio n(value) { | |||||
| 93 | return (value && typeof va lue === 'o bject') ? toString.c all(value) === '[obj ect Array] ' : false; | |||||
| 94 | }; | |||||
| 95 | __export s__.isArra y = isArra y; | |||||
| 96 | ||||||
| 97 | function escapeExp ression(st ring) { | |||||
| 98 | // don 't escape SafeString s, since t hey're alr eady safe | |||||
| 99 | if (st ring insta nceof Safe String) { | |||||
| 100 | retu rn string. toString() ; | |||||
| 101 | } else if (!stri ng && stri ng !== 0) { | |||||
| 102 | retu rn ""; | |||||
| 103 | } | |||||
| 104 | ||||||
| 105 | // For ce a strin g conversi on as this will be d one by the append re gardless a nd | |||||
| 106 | // the regex tes t will do this trans parently b ehind the scenes, ca using issu es if | |||||
| 107 | // an object's t o string h as escaped character s in it. | |||||
| 108 | string = "" + st ring; | |||||
| 109 | ||||||
| 110 | if(!po ssible.tes t(string)) { return string; } | |||||
| 111 | return string.re place(badC hars, esca peChar); | |||||
| 112 | } | |||||
| 113 | ||||||
| 114 | __export s__.escape Expression = escapeE xpression; function i sEmpty(val ue) { | |||||
| 115 | if (!v alue && va lue !== 0) { | |||||
| 116 | retu rn true; | |||||
| 117 | } else if (isArr ay(value) && value.l ength === 0) { | |||||
| 118 | retu rn true; | |||||
| 119 | } else { | |||||
| 120 | retu rn false; | |||||
| 121 | } | |||||
| 122 | } | |||||
| 123 | ||||||
| 124 | __export s__.isEmpt y = isEmpt y; | |||||
| 125 | return _ _exports__ ; | |||||
| 126 | })(__modul e4__); | |||||
| 127 | ||||||
| 128 | // handleb ars/except ion.js | |||||
| 129 | var __modu le5__ = (f unction() { | |||||
| 130 | "use str ict"; | |||||
| 131 | var __ex ports__; | |||||
| 132 | ||||||
| 133 | var erro rProps = [ 'descripti on', 'file Name', 'li neNumber', 'message' , 'name', 'number', 'stack']; | |||||
| 134 | ||||||
| 135 | function Exception (message, node) { | |||||
| 136 | var li ne; | |||||
| 137 | if (no de && node .firstLine ) { | |||||
| 138 | line = node.fi rstLine; | |||||
| 139 | ||||||
| 140 | mess age += ' - ' + line + ':' + no de.firstCo lumn; | |||||
| 141 | } | |||||
| 142 | ||||||
| 143 | var tm p = Error. prototype. constructo r.call(thi s, message ); | |||||
| 144 | ||||||
| 145 | // Unf ortunately errors ar e not enum erable in Chrome (at least), s o `for pro p in tmp` doesn't wo rk. | |||||
| 146 | for (v ar idx = 0 ; idx < er rorProps.l ength; idx ++) { | |||||
| 147 | this [errorProp s[idx]] = tmp[errorP rops[idx]] ; | |||||
| 148 | } | |||||
| 149 | ||||||
| 150 | if (li ne) { | |||||
| 151 | this .lineNumbe r = line; | |||||
| 152 | this .column = node.first Column; | |||||
| 153 | } | |||||
| 154 | } | |||||
| 155 | ||||||
| 156 | Exceptio n.prototyp e = new Er ror(); | |||||
| 157 | ||||||
| 158 | __export s__ = Exce ption; | |||||
| 159 | return _ _exports__ ; | |||||
| 160 | })(); | |||||
| 161 | ||||||
| 162 | // handleb ars/base.j s | |||||
| 163 | var __modu le2__ = (f unction(__ dependency 1__, __dep endency2__ ) { | |||||
| 164 | "use str ict"; | |||||
| 165 | var __ex ports__ = {}; | |||||
| 166 | var Util s = __depe ndency1__; | |||||
| 167 | var Exce ption = __ dependency 2__; | |||||
| 168 | ||||||
| 169 | var VERS ION = "1.3 .0"; | |||||
| 170 | __export s__.VERSIO N = VERSIO N;var COMP ILER_REVIS ION = 4; | |||||
| 171 | __export s__.COMPIL ER_REVISIO N = COMPIL ER_REVISIO N; | |||||
| 172 | var REVI SION_CHANG ES = { | |||||
| 173 | 1: '<= 1.0.rc.2' , // 1.0.r c.2 is act ually rev2 but doesn 't report it | |||||
| 174 | 2: '== 1.0.0-rc. 3', | |||||
| 175 | 3: '== 1.0.0-rc. 4', | |||||
| 176 | 4: '>= 1.0.0' | |||||
| 177 | }; | |||||
| 178 | __export s__.REVISI ON_CHANGES = REVISIO N_CHANGES; | |||||
| 179 | var isAr ray = Util s.isArray, | |||||
| 180 | isFu nction = U tils.isFun ction, | |||||
| 181 | toSt ring = Uti ls.toStrin g, | |||||
| 182 | obje ctType = ' [object Ob ject]'; | |||||
| 183 | ||||||
| 184 | function Handlebar sEnvironme nt(helpers , partials ) { | |||||
| 185 | this.h elpers = h elpers || {}; | |||||
| 186 | this.p artials = partials | | {}; | |||||
| 187 | ||||||
| 188 | regist erDefaultH elpers(thi s); | |||||
| 189 | } | |||||
| 190 | ||||||
| 191 | __export s__.Handle barsEnviro nment = Ha ndlebarsEn vironment; Handlebars Environmen t.prototyp e = { | |||||
| 192 | constr uctor: Han dlebarsEnv ironment, | |||||
| 193 | ||||||
| 194 | logger : logger, | |||||
| 195 | log: l og, | |||||
| 196 | ||||||
| 197 | regist erHelper: function(n ame, fn, i nverse) { | |||||
| 198 | if ( toString.c all(name) === object Type) { | |||||
| 199 | if (inverse || fn) { t hrow new E xception(' Arg not su pported wi th multipl e helpers' ); } | |||||
| 200 | Ut ils.extend (this.help ers, name) ; | |||||
| 201 | } el se { | |||||
| 202 | if (inverse) { fn.not = inverse; } | |||||
| 203 | th is.helpers [name] = f n; | |||||
| 204 | } | |||||
| 205 | }, | |||||
| 206 | ||||||
| 207 | regist erPartial: function( name, str) { | |||||
| 208 | if ( toString.c all(name) === object Type) { | |||||
| 209 | Ut ils.extend (this.part ials, nam e); | |||||
| 210 | } el se { | |||||
| 211 | th is.partial s[name] = str; | |||||
| 212 | } | |||||
| 213 | } | |||||
| 214 | }; | |||||
| 215 | ||||||
| 216 | function registerD efaultHelp ers(instan ce) { | |||||
| 217 | instan ce.registe rHelper('h elperMissi ng', funct ion(arg) { | |||||
| 218 | if(a rguments.l ength === 2) { | |||||
| 219 | re turn undef ined; | |||||
| 220 | } el se { | |||||
| 221 | th row new Ex ception("M issing hel per: '" + arg + "'") ; | |||||
| 222 | } | |||||
| 223 | }); | |||||
| 224 | ||||||
| 225 | instan ce.registe rHelper('b lockHelper Missing', function(c ontext, op tions) { | |||||
| 226 | var inverse = options.in verse || f unction() {}, fn = o ptions.fn; | |||||
| 227 | ||||||
| 228 | if ( isFunction (context)) { context = context .call(this ); } | |||||
| 229 | ||||||
| 230 | if(c ontext === true) { | |||||
| 231 | re turn fn(th is); | |||||
| 232 | } el se if(cont ext === fa lse || con text == nu ll) { | |||||
| 233 | re turn inver se(this); | |||||
| 234 | } el se if (isA rray(conte xt)) { | |||||
| 235 | if (context.l ength > 0) { | |||||
| 236 | return ins tance.help ers.each(c ontext, op tions); | |||||
| 237 | } else { | |||||
| 238 | return inv erse(this) ; | |||||
| 239 | } | |||||
| 240 | } el se { | |||||
| 241 | re turn fn(co ntext); | |||||
| 242 | } | |||||
| 243 | }); | |||||
| 244 | ||||||
| 245 | instan ce.registe rHelper('e ach', func tion(conte xt, option s) { | |||||
| 246 | var fn = optio ns.fn, inv erse = opt ions.inver se; | |||||
| 247 | var i = 0, ret = "", dat a; | |||||
| 248 | ||||||
| 249 | if ( isFunction (context)) { context = context .call(this ); } | |||||
| 250 | ||||||
| 251 | if ( options.da ta) { | |||||
| 252 | da ta = creat eFrame(opt ions.data) ; | |||||
| 253 | } | |||||
| 254 | ||||||
| 255 | if(c ontext && typeof con text === ' object') { | |||||
| 256 | if (isArray( context)) { | |||||
| 257 | for(var j = context. length; i< j; i++) { | |||||
| 258 | if (data ) { | |||||
| 259 | data.i ndex = i; | |||||
| 260 | data.f irst = (i === 0); | |||||
| 261 | data.l ast = (i === (conte xt.length- 1)); | |||||
| 262 | } | |||||
| 263 | ret = re t + fn(con text[i], { data: dat a }); | |||||
| 264 | } | |||||
| 265 | } else { | |||||
| 266 | for(var ke y in conte xt) { | |||||
| 267 | if(conte xt.hasOwnP roperty(ke y)) { | |||||
| 268 | if(dat a) { | |||||
| 269 | data .key = key ; | |||||
| 270 | data .index = i ; | |||||
| 271 | data .first = ( i === 0); | |||||
| 272 | } | |||||
| 273 | ret = ret + fn(c ontext[key ], {data: data}); | |||||
| 274 | i++; | |||||
| 275 | } | |||||
| 276 | } | |||||
| 277 | } | |||||
| 278 | } | |||||
| 279 | ||||||
| 280 | if(i === 0){ | |||||
| 281 | re t = invers e(this); | |||||
| 282 | } | |||||
| 283 | ||||||
| 284 | retu rn ret; | |||||
| 285 | }); | |||||
| 286 | ||||||
| 287 | instan ce.registe rHelper('i f', functi on(conditi onal, opti ons) { | |||||
| 288 | if ( isFunction (condition al)) { con ditional = condition al.call(th is); } | |||||
| 289 | ||||||
| 290 | // D efault beh avior is t o render t he positiv e path if the value is truthy and not em pty. | |||||
| 291 | // T he `includ eZero` opt ion may be set to tr eat the co ndtional a s purely n ot empty b ased on th e | |||||
| 292 | // b ehavior of isEmpty. Effectivel y this det ermines if 0 is hand led by the positive path or ne gative. | |||||
| 293 | if ( (!options. hash.inclu deZero && !condition al) || Uti ls.isEmpty (condition al)) { | |||||
| 294 | re turn optio ns.inverse (this); | |||||
| 295 | } el se { | |||||
| 296 | re turn optio ns.fn(this ); | |||||
| 297 | } | |||||
| 298 | }); | |||||
| 299 | ||||||
| 300 | instan ce.registe rHelper('u nless', fu nction(con ditional, options) { | |||||
| 301 | retu rn instanc e.helpers[ 'if'].call (this, con ditional, {fn: optio ns.inverse , inverse: options.f n, hash: o ptions.has h}); | |||||
| 302 | }); | |||||
| 303 | ||||||
| 304 | instan ce.registe rHelper('w ith', func tion(conte xt, option s) { | |||||
| 305 | if ( isFunction (context)) { context = context .call(this ); } | |||||
| 306 | ||||||
| 307 | if ( !Utils.isE mpty(conte xt)) retur n options. fn(context ); | |||||
| 308 | }); | |||||
| 309 | ||||||
| 310 | instan ce.registe rHelper('l og', funct ion(contex t, options ) { | |||||
| 311 | var level = op tions.data && option s.data.lev el != null ? parseIn t(options. data.level , 10) : 1; | |||||
| 312 | inst ance.log(l evel, cont ext); | |||||
| 313 | }); | |||||
| 314 | } | |||||
| 315 | ||||||
| 316 | var logg er = { | |||||
| 317 | method Map: { 0: 'debug', 1 : 'info', 2: 'warn', 3: 'error ' }, | |||||
| 318 | ||||||
| 319 | // Sta te enum | |||||
| 320 | DEBUG: 0, | |||||
| 321 | INFO: 1, | |||||
| 322 | WARN: 2, | |||||
| 323 | ERROR: 3, | |||||
| 324 | level: 3, | |||||
| 325 | ||||||
| 326 | // can be overri dden in th e host env ironment | |||||
| 327 | log: f unction(le vel, obj) { | |||||
| 328 | if ( logger.lev el <= leve l) { | |||||
| 329 | va r method = logger.me thodMap[le vel]; | |||||
| 330 | if (typeof c onsole !== 'undefine d' && cons ole[method ]) { | |||||
| 331 | console[me thod].call (console, obj); | |||||
| 332 | } | |||||
| 333 | } | |||||
| 334 | } | |||||
| 335 | }; | |||||
| 336 | __export s__.logger = logger; | |||||
| 337 | function log(level , obj) { l ogger.log( level, obj ); } | |||||
| 338 | ||||||
| 339 | __export s__.log = log;var cr eateFrame = function (object) { | |||||
| 340 | var ob j = {}; | |||||
| 341 | Utils. extend(obj , object); | |||||
| 342 | return obj; | |||||
| 343 | }; | |||||
| 344 | __export s__.create Frame = cr eateFrame; | |||||
| 345 | return _ _exports__ ; | |||||
| 346 | })(__modul e3__, __mo dule5__); | |||||
| 347 | ||||||
| 348 | // handleb ars/runtim e.js | |||||
| 349 | var __modu le6__ = (f unction(__ dependency 1__, __dep endency2__ , __depend ency3__) { | |||||
| 350 | "use str ict"; | |||||
| 351 | var __ex ports__ = {}; | |||||
| 352 | var Util s = __depe ndency1__; | |||||
| 353 | var Exce ption = __ dependency 2__; | |||||
| 354 | var COMP ILER_REVIS ION = __de pendency3_ _.COMPILER _REVISION; | |||||
| 355 | var REVI SION_CHANG ES = __dep endency3__ .REVISION_ CHANGES; | |||||
| 356 | ||||||
| 357 | function checkRevi sion(compi lerInfo) { | |||||
| 358 | var co mpilerRevi sion = com pilerInfo && compile rInfo[0] | | 1, | |||||
| 359 | cu rrentRevis ion = COMP ILER_REVIS ION; | |||||
| 360 | ||||||
| 361 | if (co mpilerRevi sion !== c urrentRevi sion) { | |||||
| 362 | if ( compilerRe vision < c urrentRevi sion) { | |||||
| 363 | va r runtimeV ersions = REVISION_C HANGES[cur rentRevisi on], | |||||
| 364 | compiler Versions = REVISION_ CHANGES[co mpilerRevi sion]; | |||||
| 365 | th row new Ex ception("T emplate wa s precompi led with a n older ve rsion of H andlebars than the c urrent run time. "+ | |||||
| 366 | "Pleas e update y our precom piler to a newer ver sion ("+ru ntimeVersi ons+") or downgrade your runti me to an o lder versi on ("+comp ilerVersio ns+")."); | |||||
| 367 | } el se { | |||||
| 368 | // Use the e mbedded ve rsion info since the runtime d oesn't kno w about th is revisio n yet | |||||
| 369 | th row new Ex ception("T emplate wa s precompi led with a newer ver sion of Ha ndlebars t han the cu rrent runt ime. "+ | |||||
| 370 | "Pleas e update y our runtim e to a new er version ("+compil erInfo[1]+ ")."); | |||||
| 371 | } | |||||
| 372 | } | |||||
| 373 | } | |||||
| 374 | ||||||
| 375 | __export s__.checkR evision = checkRevis ion;// TOD O: Remove this line and break up compile Partial | |||||
| 376 | ||||||
| 377 | function template( templateSp ec, env) { | |||||
| 378 | if (!e nv) { | |||||
| 379 | thro w new Exce ption("No environmen t passed t o template "); | |||||
| 380 | } | |||||
| 381 | ||||||
| 382 | // Not e: Using e nv.VM refe rences rat her than l ocal var r eferences throughout this sect ion to all ow | |||||
| 383 | // for external users to o verride th ese as psu edo-suppor ted APIs. | |||||
| 384 | var in vokePartia lWrapper = function( partial, n ame, conte xt, helper s, partial s, data) { | |||||
| 385 | var result = e nv.VM.invo kePartial. apply(this , argument s); | |||||
| 386 | if ( result != null) { re turn resul t; } | |||||
| 387 | ||||||
| 388 | if ( env.compil e) { | |||||
| 389 | va r options = { helper s: helpers , partials : partials , data: da ta }; | |||||
| 390 | pa rtials[nam e] = env.c ompile(par tial, { da ta: data ! == undefin ed }, env) ; | |||||
| 391 | re turn parti als[name]( context, o ptions); | |||||
| 392 | } el se { | |||||
| 393 | th row new Ex ception("T he partial " + name + " could not be com piled when running i n runtime- only mode" ); | |||||
| 394 | } | |||||
| 395 | }; | |||||
| 396 | ||||||
| 397 | // Jus t add wate r | |||||
| 398 | var co ntainer = { | |||||
| 399 | esca peExpressi on: Utils. escapeExpr ession, | |||||
| 400 | invo kePartial: invokePar tialWrappe r, | |||||
| 401 | prog rams: [], | |||||
| 402 | prog ram: funct ion(i, fn, data) { | |||||
| 403 | va r programW rapper = t his.progra ms[i]; | |||||
| 404 | if (data) { | |||||
| 405 | programWra pper = pro gram(i, fn , data); | |||||
| 406 | } else if (! programWra pper) { | |||||
| 407 | programWra pper = thi s.programs [i] = prog ram(i, fn) ; | |||||
| 408 | } | |||||
| 409 | re turn progr amWrapper; | |||||
| 410 | }, | |||||
| 411 | merg e: functio n(param, c ommon) { | |||||
| 412 | va r ret = pa ram || com mon; | |||||
| 413 | ||||||
| 414 | if (param && common && (param != = common)) { | |||||
| 415 | ret = {}; | |||||
| 416 | Utils.exte nd(ret, co mmon); | |||||
| 417 | Utils.exte nd(ret, pa ram); | |||||
| 418 | } | |||||
| 419 | re turn ret; | |||||
| 420 | }, | |||||
| 421 | prog ramWithDep th: env.VM .programWi thDepth, | |||||
| 422 | noop : env.VM.n oop, | |||||
| 423 | comp ilerInfo: null | |||||
| 424 | }; | |||||
| 425 | ||||||
| 426 | return function( context, o ptions) { | |||||
| 427 | opti ons = opti ons || {}; | |||||
| 428 | var namespace = options. partial ? options : env, | |||||
| 429 | helpers, | |||||
| 430 | partials; | |||||
| 431 | ||||||
| 432 | if ( !options.p artial) { | |||||
| 433 | he lpers = op tions.help ers; | |||||
| 434 | pa rtials = o ptions.par tials; | |||||
| 435 | } | |||||
| 436 | var result = t emplateSpe c.call( | |||||
| 437 | containe r, | |||||
| 438 | namespac e, context , | |||||
| 439 | helpers, | |||||
| 440 | partials , | |||||
| 441 | options. data); | |||||
| 442 | ||||||
| 443 | if ( !options.p artial) { | |||||
| 444 | en v.VM.check Revision(c ontainer.c ompilerInf o); | |||||
| 445 | } | |||||
| 446 | ||||||
| 447 | retu rn result; | |||||
| 448 | }; | |||||
| 449 | } | |||||
| 450 | ||||||
| 451 | __export s__.templa te = templ ate;functi on program WithDepth( i, fn, dat a /*, $dep th */) { | |||||
| 452 | var ar gs = Array .prototype .slice.cal l(argument s, 3); | |||||
| 453 | ||||||
| 454 | var pr og = funct ion(contex t, options ) { | |||||
| 455 | opti ons = opti ons || {}; | |||||
| 456 | ||||||
| 457 | retu rn fn.appl y(this, [c ontext, op tions.data || data]. concat(arg s)); | |||||
| 458 | }; | |||||
| 459 | prog.p rogram = i ; | |||||
| 460 | prog.d epth = arg s.length; | |||||
| 461 | return prog; | |||||
| 462 | } | |||||
| 463 | ||||||
| 464 | __export s__.progra mWithDepth = program WithDepth; function p rogram(i, fn, data) { | |||||
| 465 | var pr og = funct ion(contex t, options ) { | |||||
| 466 | opti ons = opti ons || {}; | |||||
| 467 | ||||||
| 468 | retu rn fn(cont ext, optio ns.data || data); | |||||
| 469 | }; | |||||
| 470 | prog.p rogram = i ; | |||||
| 471 | prog.d epth = 0; | |||||
| 472 | return prog; | |||||
| 473 | } | |||||
| 474 | ||||||
| 475 | __export s__.progra m = progra m;function invokePar tial(parti al, name, context, h elpers, pa rtials, da ta) { | |||||
| 476 | var op tions = { partial: t rue, helpe rs: helper s, partial s: partial s, data: d ata }; | |||||
| 477 | ||||||
| 478 | if(par tial === u ndefined) { | |||||
| 479 | thro w new Exce ption("The partial " + name + " could no t be found "); | |||||
| 480 | } else if(partia l instance of Functio n) { | |||||
| 481 | retu rn partial (context, options); | |||||
| 482 | } | |||||
| 483 | } | |||||
| 484 | ||||||
| 485 | __export s__.invoke Partial = invokePart ial;functi on noop() { return " "; } | |||||
| 486 | ||||||
| 487 | __export s__.noop = noop; | |||||
| 488 | return _ _exports__ ; | |||||
| 489 | })(__modul e3__, __mo dule5__, _ _module2__ ); | |||||
| 490 | ||||||
| 491 | // handleb ars.runtim e.js | |||||
| 492 | var __modu le1__ = (f unction(__ dependency 1__, __dep endency2__ , __depend ency3__, _ _dependenc y4__, __de pendency5_ _) { | |||||
| 493 | "use str ict"; | |||||
| 494 | var __ex ports__; | |||||
| 495 | /*global s Handleba rs: true * / | |||||
| 496 | var base = __depen dency1__; | |||||
| 497 | ||||||
| 498 | // Each of these a ugment the Handlebar s object. No need to setup her e. | |||||
| 499 | // (This is done t o easily s hare code between co mmonjs and browse en vs) | |||||
| 500 | var Safe String = _ _dependenc y2__; | |||||
| 501 | var Exce ption = __ dependency 3__; | |||||
| 502 | var Util s = __depe ndency4__; | |||||
| 503 | var runt ime = __de pendency5_ _; | |||||
| 504 | ||||||
| 505 | // For c ompatibili ty and usa ge outside of module systems, make the H andlebars object a n amespace | |||||
| 506 | var crea te = funct ion() { | |||||
| 507 | var hb = new bas e.Handleba rsEnvironm ent(); | |||||
| 508 | ||||||
| 509 | Utils. extend(hb, base); | |||||
| 510 | hb.Saf eString = SafeString ; | |||||
| 511 | hb.Exc eption = E xception; | |||||
| 512 | hb.Uti ls = Utils ; | |||||
| 513 | ||||||
| 514 | hb.VM = runtime; | |||||
| 515 | hb.tem plate = fu nction(spe c) { | |||||
| 516 | retu rn runtime .template( spec, hb); | |||||
| 517 | }; | |||||
| 518 | ||||||
| 519 | return hb; | |||||
| 520 | }; | |||||
| 521 | ||||||
| 522 | var Hand lebars = c reate(); | |||||
| 523 | Handleba rs.create = create; | |||||
| 524 | ||||||
| 525 | __export s__ = Hand lebars; | |||||
| 526 | return _ _exports__ ; | |||||
| 527 | })(__modul e2__, __mo dule4__, _ _module5__ , __module 3__, __mod ule6__); | |||||
| 528 | ||||||
| 529 | // handleb ars/compil er/ast.js | |||||
| 530 | var __modu le7__ = (f unction(__ dependency 1__) { | |||||
| 531 | "use str ict"; | |||||
| 532 | var __ex ports__; | |||||
| 533 | var Exce ption = __ dependency 1__; | |||||
| 534 | ||||||
| 535 | function LocationI nfo(locInf o){ | |||||
| 536 | locInf o = locInf o || {}; | |||||
| 537 | this.f irstLine = locInfo .first_lin e; | |||||
| 538 | this.f irstColumn = locInfo .first_col umn; | |||||
| 539 | this.l astColumn = locInfo .last_colu mn; | |||||
| 540 | this.l astLine = locInfo .last_line ; | |||||
| 541 | } | |||||
| 542 | ||||||
| 543 | var AST = { | |||||
| 544 | Progra mNode: fun ction(stat ements, in verseStrip , inverse, locInfo) { | |||||
| 545 | var inverseLoc ationInfo, firstInve rseNode; | |||||
| 546 | if ( arguments. length === 3) { | |||||
| 547 | lo cInfo = in verse; | |||||
| 548 | in verse = nu ll; | |||||
| 549 | } el se if (arg uments.len gth === 2) { | |||||
| 550 | lo cInfo = in verseStrip ; | |||||
| 551 | in verseStrip = null; | |||||
| 552 | } | |||||
| 553 | ||||||
| 554 | Loca tionInfo.c all(this, locInfo); | |||||
| 555 | this .type = "p rogram"; | |||||
| 556 | this .statement s = statem ents; | |||||
| 557 | this .strip = { }; | |||||
| 558 | ||||||
| 559 | if(i nverse) { | |||||
| 560 | fi rstInverse Node = inv erse[0]; | |||||
| 561 | if (firstInv erseNode) { | |||||
| 562 | inverseLoc ationInfo = { | |||||
| 563 | first_li ne: firstI nverseNode .firstLine , | |||||
| 564 | last_lin e: firstIn verseNode. lastLine, | |||||
| 565 | last_col umn: first InverseNod e.lastColu mn, | |||||
| 566 | first_co lumn: firs tInverseNo de.firstCo lumn | |||||
| 567 | }; | |||||
| 568 | this.inver se = new A ST.Program Node(inver se, invers eStrip, in verseLocat ionInfo); | |||||
| 569 | } else { | |||||
| 570 | this.inver se = new A ST.Program Node(inver se, invers eStrip); | |||||
| 571 | } | |||||
| 572 | th is.strip.r ight = inv erseStrip. left; | |||||
| 573 | } el se if (inv erseStrip) { | |||||
| 574 | th is.strip.l eft = inve rseStrip.r ight; | |||||
| 575 | } | |||||
| 576 | }, | |||||
| 577 | ||||||
| 578 | Mustac heNode: fu nction(raw Params, ha sh, open, strip, loc Info) { | |||||
| 579 | Loca tionInfo.c all(this, locInfo); | |||||
| 580 | this .type = "m ustache"; | |||||
| 581 | this .strip = s trip; | |||||
| 582 | ||||||
| 583 | // O pen may be a string parsed fro m the pars er or a pa ssed boole an flag | |||||
| 584 | if ( open != nu ll && open .charAt) { | |||||
| 585 | // Must use charAt to support IE pre-10 | |||||
| 586 | va r escapeFl ag = open. charAt(3) || open.ch arAt(2); | |||||
| 587 | th is.escaped = escapeF lag !== '{ ' && escap eFlag !== '&'; | |||||
| 588 | } el se { | |||||
| 589 | th is.escaped = !!open; | |||||
| 590 | } | |||||
| 591 | ||||||
| 592 | if ( rawParams instanceof AST.Sexpr Node) { | |||||
| 593 | th is.sexpr = rawParams ; | |||||
| 594 | } el se { | |||||
| 595 | // Support o ld AST API | |||||
| 596 | th is.sexpr = new AST.S exprNode(r awParams, hash); | |||||
| 597 | } | |||||
| 598 | ||||||
| 599 | this .sexpr.isR oot = true ; | |||||
| 600 | ||||||
| 601 | // S upport old AST API t hat stored this info in Mustac heNode | |||||
| 602 | this .id = this .sexpr.id; | |||||
| 603 | this .params = this.sexpr .params; | |||||
| 604 | this .hash = th is.sexpr.h ash; | |||||
| 605 | this .eligibleH elper = th is.sexpr.e ligibleHel per; | |||||
| 606 | this .isHelper = this.sex pr.isHelpe r; | |||||
| 607 | }, | |||||
| 608 | ||||||
| 609 | SexprN ode: funct ion(rawPar ams, hash, locInfo) { | |||||
| 610 | Loca tionInfo.c all(this, locInfo); | |||||
| 611 | ||||||
| 612 | this .type = "s expr"; | |||||
| 613 | this .hash = ha sh; | |||||
| 614 | ||||||
| 615 | var id = this. id = rawPa rams[0]; | |||||
| 616 | var params = t his.params = rawPara ms.slice(1 ); | |||||
| 617 | ||||||
| 618 | // a mustache is an elig ible helpe r if: | |||||
| 619 | // * its id is simple (a single pa rt, not `t his` or `. .`) | |||||
| 620 | var eligibleHe lper = thi s.eligible Helper = i d.isSimple ; | |||||
| 621 | ||||||
| 622 | // a mustache is definit ely a help er if: | |||||
| 623 | // * it is an eligible h elper, and | |||||
| 624 | // * it has at least one parameter or hash s egment | |||||
| 625 | this .isHelper = eligible Helper && (params.le ngth || ha sh); | |||||
| 626 | ||||||
| 627 | // i f a mustac he is an e ligible he lper but n ot a defin ite | |||||
| 628 | // h elper, it is ambiguo us, and wi ll be reso lved in a later | |||||
| 629 | // p ass or at runtime. | |||||
| 630 | }, | |||||
| 631 | ||||||
| 632 | Partia lNode: fun ction(part ialName, c ontext, st rip, locIn fo) { | |||||
| 633 | Loca tionInfo.c all(this, locInfo); | |||||
| 634 | this .type = "par tial"; | |||||
| 635 | this .partialNa me = part ialName; | |||||
| 636 | this .context = cont ext; | |||||
| 637 | this .strip = s trip; | |||||
| 638 | }, | |||||
| 639 | ||||||
| 640 | BlockN ode: funct ion(mustac he, progra m, inverse , close, l ocInfo) { | |||||
| 641 | Loca tionInfo.c all(this, locInfo); | |||||
| 642 | ||||||
| 643 | if(m ustache.se xpr.id.ori ginal !== close.path .original) { | |||||
| 644 | th row new Ex ception(mu stache.sex pr.id.orig inal + " d oesn't mat ch " + clo se.path.or iginal, th is); | |||||
| 645 | } | |||||
| 646 | ||||||
| 647 | this .type = 'b lock'; | |||||
| 648 | this .mustache = mustache ; | |||||
| 649 | this .program = program; | |||||
| 650 | this .inverse = inverse; | |||||
| 651 | ||||||
| 652 | this .strip = { | |||||
| 653 | le ft: mustac he.strip.l eft, | |||||
| 654 | ri ght: close .strip.rig ht | |||||
| 655 | }; | |||||
| 656 | ||||||
| 657 | (pro gram || in verse).str ip.left = mustache.s trip.right ; | |||||
| 658 | (inv erse || pr ogram).str ip.right = close.str ip.left; | |||||
| 659 | ||||||
| 660 | if ( inverse && !program) { | |||||
| 661 | th is.isInver se = true; | |||||
| 662 | } | |||||
| 663 | }, | |||||
| 664 | ||||||
| 665 | Conten tNode: fun ction(stri ng, locInf o) { | |||||
| 666 | Loca tionInfo.c all(this, locInfo); | |||||
| 667 | this .type = "c ontent"; | |||||
| 668 | this .string = string; | |||||
| 669 | }, | |||||
| 670 | ||||||
| 671 | HashNo de: functi on(pairs, locInfo) { | |||||
| 672 | Loca tionInfo.c all(this, locInfo); | |||||
| 673 | this .type = "h ash"; | |||||
| 674 | this .pairs = p airs; | |||||
| 675 | }, | |||||
| 676 | ||||||
| 677 | IdNode : function (parts, lo cInfo) { | |||||
| 678 | Loca tionInfo.c all(this, locInfo); | |||||
| 679 | this .type = "I D"; | |||||
| 680 | ||||||
| 681 | var original = "", | |||||
| 682 | dig = [], | |||||
| 683 | depth = 0; | |||||
| 684 | ||||||
| 685 | for( var i=0,l= parts.leng th; i<l; i ++) { | |||||
| 686 | va r part = p arts[i].pa rt; | |||||
| 687 | or iginal += (parts[i]. separator || '') + p art; | |||||
| 688 | ||||||
| 689 | if (part === ".." || p art === ". " || part === "this" ) { | |||||
| 690 | if (dig.le ngth > 0) { | |||||
| 691 | throw ne w Exceptio n("Invalid path: " + original, this); | |||||
| 692 | } else if (part === "..") { | |||||
| 693 | depth++; | |||||
| 694 | } else { | |||||
| 695 | this.isS coped = tr ue; | |||||
| 696 | } | |||||
| 697 | } else { | |||||
| 698 | dig.push(p art); | |||||
| 699 | } | |||||
| 700 | } | |||||
| 701 | ||||||
| 702 | this .original = original ; | |||||
| 703 | this .parts = dig; | |||||
| 704 | this .string = dig.join ('.'); | |||||
| 705 | this .depth = depth; | |||||
| 706 | ||||||
| 707 | // a n ID is si mple if it only has one part, and that p art is not | |||||
| 708 | // ` ..` or `th is`. | |||||
| 709 | this .isSimple = parts.le ngth === 1 && !this. isScoped & & depth == = 0; | |||||
| 710 | ||||||
| 711 | this .stringMod eValue = t his.string ; | |||||
| 712 | }, | |||||
| 713 | ||||||
| 714 | Partia lNameNode: function( name, locI nfo) { | |||||
| 715 | Loca tionInfo.c all(this, locInfo); | |||||
| 716 | this .type = "P ARTIAL_NAM E"; | |||||
| 717 | this .name = na me.origina l; | |||||
| 718 | }, | |||||
| 719 | ||||||
| 720 | DataNo de: functi on(id, loc Info) { | |||||
| 721 | Loca tionInfo.c all(this, locInfo); | |||||
| 722 | this .type = "D ATA"; | |||||
| 723 | this .id = id; | |||||
| 724 | }, | |||||
| 725 | ||||||
| 726 | String Node: func tion(strin g, locInfo ) { | |||||
| 727 | Loca tionInfo.c all(this, locInfo); | |||||
| 728 | this .type = "S TRING"; | |||||
| 729 | this .original = | |||||
| 730 | th is.string = | |||||
| 731 | th is.stringM odeValue = string; | |||||
| 732 | }, | |||||
| 733 | ||||||
| 734 | Intege rNode: fun ction(inte ger, locIn fo) { | |||||
| 735 | Loca tionInfo.c all(this, locInfo); | |||||
| 736 | this .type = "I NTEGER"; | |||||
| 737 | this .original = | |||||
| 738 | th is.integer = integer ; | |||||
| 739 | this .stringMod eValue = N umber(inte ger); | |||||
| 740 | }, | |||||
| 741 | ||||||
| 742 | Boolea nNode: fun ction(bool , locInfo) { | |||||
| 743 | Loca tionInfo.c all(this, locInfo); | |||||
| 744 | this .type = "B OOLEAN"; | |||||
| 745 | this .bool = bo ol; | |||||
| 746 | this .stringMod eValue = b ool === "t rue"; | |||||
| 747 | }, | |||||
| 748 | ||||||
| 749 | Commen tNode: fun ction(comm ent, locIn fo) { | |||||
| 750 | Loca tionInfo.c all(this, locInfo); | |||||
| 751 | this .type = "c omment"; | |||||
| 752 | this .comment = comment; | |||||
| 753 | } | |||||
| 754 | }; | |||||
| 755 | ||||||
| 756 | // Must be exporte d as an ob ject rathe r than the root of t he module as the jis on lexer | |||||
| 757 | // most modify the object to operate p roperly. | |||||
| 758 | __export s__ = AST; | |||||
| 759 | return _ _exports__ ; | |||||
| 760 | })(__modul e5__); | |||||
| 761 | ||||||
| 762 | // handleb ars/compil er/parser. js | |||||
| 763 | var __modu le9__ = (f unction() { | |||||
| 764 | "use str ict"; | |||||
| 765 | var __ex ports__; | |||||
| 766 | /* jshin t ignore:s tart */ | |||||
| 767 | /* Jison generated parser */ | |||||
| 768 | var hand lebars = ( function() { | |||||
| 769 | var pars er = {trac e: functio n trace() { }, | |||||
| 770 | yy: {}, | |||||
| 771 | symbols_ : {"error" :2,"root": 3,"stateme nts":4,"EO F":5,"prog ram":6,"si mpleInvers e":7,"stat ement":8," openInvers e":9,"clos eBlock":10 ,"openBloc k":11,"mus tache":12, "partial": 13,"CONTEN T":14,"COM MENT":15," OPEN_BLOCK ":16,"sexp r":17,"CLO SE":18,"OP EN_INVERSE ":19,"OPEN _ENDBLOCK" :20,"path" :21,"OPEN" :22,"OPEN_ UNESCAPED" :23,"CLOSE _UNESCAPED ":24,"OPEN _PARTIAL": 25,"partia lName":26, "partial_o ption0":27 ,"sexpr_re petition0" :28,"sexpr _option0": 29,"dataNa me":30,"pa ram":31,"S TRING":32, "INTEGER": 33,"BOOLEA N":34,"OPE N_SEXPR":3 5,"CLOSE_S EXPR":36," hash":37," hash_repet ition_plus 0":38,"has hSegment": 39,"ID":40 ,"EQUALS": 41,"DATA": 42,"pathSe gments":43 ,"SEP":44, "$accept": 0,"$end":1 }, | |||||
| 772 | terminal s_: {2:"er ror",5:"EO F",14:"CON TENT",15:" COMMENT",1 6:"OPEN_BL OCK",18:"C LOSE",19:" OPEN_INVER SE",20:"OP EN_ENDBLOC K",22:"OPE N",23:"OPE N_UNESCAPE D",24:"CLO SE_UNESCAP ED",25:"OP EN_PARTIAL ",32:"STRI NG",33:"IN TEGER",34: "BOOLEAN", 35:"OPEN_S EXPR",36:" CLOSE_SEXP R",40:"ID" ,41:"EQUAL S",42:"DAT A",44:"SEP "}, | |||||
| 773 | producti ons_: [0,[ 3,2],[3,1] ,[6,2],[6, 3],[6,2],[ 6,1],[6,1] ,[6,0],[4, 1],[4,2],[ 8,3],[8,3] ,[8,1],[8, 1],[8,1],[ 8,1],[11,3 ],[9,3],[1 0,3],[12,3 ],[12,3],[ 13,4],[7,2 ],[17,3],[ 17,1],[31, 1],[31,1], [31,1],[31 ,1],[31,1] ,[31,3],[3 7,1],[39,3 ],[26,1],[ 26,1],[26, 1],[30,2], [21,1],[43 ,3],[43,1] ,[27,0],[2 7,1],[28,0 ],[28,2],[ 29,0],[29, 1],[38,1], [38,2]], | |||||
| 774 | performA ction: fun ction anon ymous(yyte xt,yyleng, yylineno,y y,yystate, $$,_$) { | |||||
| 775 | ||||||
| 776 | var $0 = $$.length - 1; | |||||
| 777 | switch ( yystate) { | |||||
| 778 | case 1: return new yy.Progra mNode($$[$ 0-1], this ._$); | |||||
| 779 | break; | |||||
| 780 | case 2: return new yy.Progra mNode([], this._$); | |||||
| 781 | break; | |||||
| 782 | case 3:t his.$ = ne w yy.Progr amNode([], $$[$0-1], $$[$0], t his._$); | |||||
| 783 | break; | |||||
| 784 | case 4:t his.$ = ne w yy.Progr amNode($$[ $0-2], $$[ $0-1], $$[ $0], this. _$); | |||||
| 785 | break; | |||||
| 786 | case 5:t his.$ = ne w yy.Progr amNode($$[ $0-1], $$[ $0], [], t his._$); | |||||
| 787 | break; | |||||
| 788 | case 6:t his.$ = ne w yy.Progr amNode($$[ $0], this. _$); | |||||
| 789 | break; | |||||
| 790 | case 7:t his.$ = ne w yy.Progr amNode([], this._$); | |||||
| 791 | break; | |||||
| 792 | case 8:t his.$ = ne w yy.Progr amNode([], this._$); | |||||
| 793 | break; | |||||
| 794 | case 9:t his.$ = [$ $[$0]]; | |||||
| 795 | break; | |||||
| 796 | case 10: $$[$0-1]. push($$[$0 ]); this.$ = $$[$0-1 ]; | |||||
| 797 | break; | |||||
| 798 | case 11: this.$ = n ew yy.Bloc kNode($$[$ 0-2], $$[$ 0-1].inver se, $$[$0- 1], $$[$0] , this._$) ; | |||||
| 799 | break; | |||||
| 800 | case 12: this.$ = n ew yy.Bloc kNode($$[$ 0-2], $$[$ 0-1], $$[$ 0-1].inver se, $$[$0] , this._$) ; | |||||
| 801 | break; | |||||
| 802 | case 13: this.$ = $ $[$0]; | |||||
| 803 | break; | |||||
| 804 | case 14: this.$ = $ $[$0]; | |||||
| 805 | break; | |||||
| 806 | case 15: this.$ = n ew yy.Cont entNode($$ [$0], this ._$); | |||||
| 807 | break; | |||||
| 808 | case 16: this.$ = n ew yy.Comm entNode($$ [$0], this ._$); | |||||
| 809 | break; | |||||
| 810 | case 17: this.$ = n ew yy.Must acheNode($ $[$0-1], n ull, $$[$0 -2], strip Flags($$[$ 0-2], $$[$ 0]), this. _$); | |||||
| 811 | break; | |||||
| 812 | case 18: this.$ = n ew yy.Must acheNode($ $[$0-1], n ull, $$[$0 -2], strip Flags($$[$ 0-2], $$[$ 0]), this. _$); | |||||
| 813 | break; | |||||
| 814 | case 19: this.$ = { path: $$[$ 0-1], stri p: stripFl ags($$[$0- 2], $$[$0] )}; | |||||
| 815 | break; | |||||
| 816 | case 20: this.$ = n ew yy.Must acheNode($ $[$0-1], n ull, $$[$0 -2], strip Flags($$[$ 0-2], $$[$ 0]), this. _$); | |||||
| 817 | break; | |||||
| 818 | case 21: this.$ = n ew yy.Must acheNode($ $[$0-1], n ull, $$[$0 -2], strip Flags($$[$ 0-2], $$[$ 0]), this. _$); | |||||
| 819 | break; | |||||
| 820 | case 22: this.$ = n ew yy.Part ialNode($$ [$0-2], $$ [$0-1], st ripFlags($ $[$0-3], $ $[$0]), th is._$); | |||||
| 821 | break; | |||||
| 822 | case 23: this.$ = s tripFlags( $$[$0-1], $$[$0]); | |||||
| 823 | break; | |||||
| 824 | case 24: this.$ = n ew yy.Sexp rNode([$$[ $0-2]].con cat($$[$0- 1]), $$[$0 ], this._$ ); | |||||
| 825 | break; | |||||
| 826 | case 25: this.$ = n ew yy.Sexp rNode([$$[ $0]], null , this._$) ; | |||||
| 827 | break; | |||||
| 828 | case 26: this.$ = $ $[$0]; | |||||
| 829 | break; | |||||
| 830 | case 27: this.$ = n ew yy.Stri ngNode($$[ $0], this. _$); | |||||
| 831 | break; | |||||
| 832 | case 28: this.$ = n ew yy.Inte gerNode($$ [$0], this ._$); | |||||
| 833 | break; | |||||
| 834 | case 29: this.$ = n ew yy.Bool eanNode($$ [$0], this ._$); | |||||
| 835 | break; | |||||
| 836 | case 30: this.$ = $ $[$0]; | |||||
| 837 | break; | |||||
| 838 | case 31: $$[$0-1].i sHelper = true; this .$ = $$[$0 -1]; | |||||
| 839 | break; | |||||
| 840 | case 32: this.$ = n ew yy.Hash Node($$[$0 ], this._$ ); | |||||
| 841 | break; | |||||
| 842 | case 33: this.$ = [ $$[$0-2], $$[$0]]; | |||||
| 843 | break; | |||||
| 844 | case 34: this.$ = n ew yy.Part ialNameNod e($$[$0], this._$); | |||||
| 845 | break; | |||||
| 846 | case 35: this.$ = n ew yy.Part ialNameNod e(new yy.S tringNode( $$[$0], th is._$), th is._$); | |||||
| 847 | break; | |||||
| 848 | case 36: this.$ = n ew yy.Part ialNameNod e(new yy.I ntegerNode ($$[$0], t his._$)); | |||||
| 849 | break; | |||||
| 850 | case 37: this.$ = n ew yy.Data Node($$[$0 ], this._$ ); | |||||
| 851 | break; | |||||
| 852 | case 38: this.$ = n ew yy.IdNo de($$[$0], this._$); | |||||
| 853 | break; | |||||
| 854 | case 39: $$[$0-2]. push({part : $$[$0], separator: $$[$0-1]} ); this.$ = $$[$0-2] ; | |||||
| 855 | break; | |||||
| 856 | case 40: this.$ = [ {part: $$[ $0]}]; | |||||
| 857 | break; | |||||
| 858 | case 43: this.$ = [ ]; | |||||
| 859 | break; | |||||
| 860 | case 44: $$[$0-1].p ush($$[$0] ); | |||||
| 861 | break; | |||||
| 862 | case 47: this.$ = [ $$[$0]]; | |||||
| 863 | break; | |||||
| 864 | case 48: $$[$0-1].p ush($$[$0] ); | |||||
| 865 | break; | |||||
| 866 | } | |||||
| 867 | }, | |||||
| 868 | table: [ {3:1,4:2,5 :[1,3],8:4 ,9:5,11:6, 12:7,13:8, 14:[1,9],1 5:[1,10],1 6:[1,12],1 9:[1,11],2 2:[1,13],2 3:[1,14],2 5:[1,15]}, {1:[3]},{5 :[1,16],8: 17,9:5,11: 6,12:7,13: 8,14:[1,9] ,15:[1,10] ,16:[1,12] ,19:[1,11] ,22:[1,13] ,23:[1,14] ,25:[1,15] },{1:[2,2] },{5:[2,9] ,14:[2,9], 15:[2,9],1 6:[2,9],19 :[2,9],20: [2,9],22:[ 2,9],23:[2 ,9],25:[2, 9]},{4:20, 6:18,7:19, 8:4,9:5,11 :6,12:7,13 :8,14:[1,9 ],15:[1,10 ],16:[1,12 ],19:[1,21 ],20:[2,8] ,22:[1,13] ,23:[1,14] ,25:[1,15] },{4:20,6: 22,7:19,8: 4,9:5,11:6 ,12:7,13:8 ,14:[1,9], 15:[1,10], 16:[1,12], 19:[1,21], 20:[2,8],2 2:[1,13],2 3:[1,14],2 5:[1,15]}, {5:[2,13], 14:[2,13], 15:[2,13], 16:[2,13], 19:[2,13], 20:[2,13], 22:[2,13], 23:[2,13], 25:[2,13]} ,{5:[2,14] ,14:[2,14] ,15:[2,14] ,16:[2,14] ,19:[2,14] ,20:[2,14] ,22:[2,14] ,23:[2,14] ,25:[2,14] },{5:[2,15 ],14:[2,15 ],15:[2,15 ],16:[2,15 ],19:[2,15 ],20:[2,15 ],22:[2,15 ],23:[2,15 ],25:[2,15 ]},{5:[2,1 6],14:[2,1 6],15:[2,1 6],16:[2,1 6],19:[2,1 6],20:[2,1 6],22:[2,1 6],23:[2,1 6],25:[2,1 6]},{17:23 ,21:24,30: 25,40:[1,2 8],42:[1,2 7],43:26}, {17:29,21: 24,30:25,4 0:[1,28],4 2:[1,27],4 3:26},{17: 30,21:24,3 0:25,40:[1 ,28],42:[1 ,27],43:26 },{17:31,2 1:24,30:25 ,40:[1,28] ,42:[1,27] ,43:26},{2 1:33,26:32 ,32:[1,34] ,33:[1,35] ,40:[1,28] ,43:26},{1 :[2,1]},{5 :[2,10],14 :[2,10],15 :[2,10],16 :[2,10],19 :[2,10],20 :[2,10],22 :[2,10],23 :[2,10],25 :[2,10]},{ 10:36,20:[ 1,37]},{4: 38,8:4,9:5 ,11:6,12:7 ,13:8,14:[ 1,9],15:[1 ,10],16:[1 ,12],19:[1 ,11],20:[2 ,7],22:[1, 13],23:[1, 14],25:[1, 15]},{7:39 ,8:17,9:5, 11:6,12:7, 13:8,14:[1 ,9],15:[1, 10],16:[1, 12],19:[1, 21],20:[2, 6],22:[1,1 3],23:[1,1 4],25:[1,1 5]},{17:23 ,18:[1,40] ,21:24,30: 25,40:[1,2 8],42:[1,2 7],43:26}, {10:41,20: [1,37]},{1 8:[1,42]}, {18:[2,43] ,24:[2,43] ,28:43,32: [2,43],33: [2,43],34: [2,43],35: [2,43],36: [2,43],40: [2,43],42: [2,43]},{1 8:[2,25],2 4:[2,25],3 6:[2,25]}, {18:[2,38] ,24:[2,38] ,32:[2,38] ,33:[2,38] ,34:[2,38] ,35:[2,38] ,36:[2,38] ,40:[2,38] ,42:[2,38] ,44:[1,44] },{21:45,4 0:[1,28],4 3:26},{18: [2,40],24: [2,40],32: [2,40],33: [2,40],34: [2,40],35: [2,40],36: [2,40],40: [2,40],42: [2,40],44: [2,40]},{1 8:[1,46]}, {18:[1,47] },{24:[1,4 8]},{18:[2 ,41],21:50 ,27:49,40: [1,28],43: 26},{18:[2 ,34],40:[2 ,34]},{18: [2,35],40: [2,35]},{1 8:[2,36],4 0:[2,36]}, {5:[2,11], 14:[2,11], 15:[2,11], 16:[2,11], 19:[2,11], 20:[2,11], 22:[2,11], 23:[2,11], 25:[2,11]} ,{21:51,40 :[1,28],43 :26},{8:17 ,9:5,11:6, 12:7,13:8, 14:[1,9],1 5:[1,10],1 6:[1,12],1 9:[1,11],2 0:[2,3],22 :[1,13],23 :[1,14],25 :[1,15]},{ 4:52,8:4,9 :5,11:6,12 :7,13:8,14 :[1,9],15: [1,10],16: [1,12],19: [1,11],20: [2,5],22:[ 1,13],23:[ 1,14],25:[ 1,15]},{14 :[2,23],15 :[2,23],16 :[2,23],19 :[2,23],20 :[2,23],22 :[2,23],23 :[2,23],25 :[2,23]},{ 5:[2,12],1 4:[2,12],1 5:[2,12],1 6:[2,12],1 9:[2,12],2 0:[2,12],2 2:[2,12],2 3:[2,12],2 5:[2,12]}, {14:[2,18] ,15:[2,18] ,16:[2,18] ,19:[2,18] ,20:[2,18] ,22:[2,18] ,23:[2,18] ,25:[2,18] },{18:[2,4 5],21:56,2 4:[2,45],2 9:53,30:60 ,31:54,32: [1,57],33: [1,58],34: [1,59],35: [1,61],36: [2,45],37: 55,38:62,3 9:63,40:[1 ,64],42:[1 ,27],43:26 },{40:[1,6 5]},{18:[2 ,37],24:[2 ,37],32:[2 ,37],33:[2 ,37],34:[2 ,37],35:[2 ,37],36:[2 ,37],40:[2 ,37],42:[2 ,37]},{14: [2,17],15: [2,17],16: [2,17],19: [2,17],20: [2,17],22: [2,17],23: [2,17],25: [2,17]},{5 :[2,20],14 :[2,20],15 :[2,20],16 :[2,20],19 :[2,20],20 :[2,20],22 :[2,20],23 :[2,20],25 :[2,20]},{ 5:[2,21],1 4:[2,21],1 5:[2,21],1 6:[2,21],1 9:[2,21],2 0:[2,21],2 2:[2,21],2 3:[2,21],2 5:[2,21]}, {18:[1,66] },{18:[2,4 2]},{18:[1 ,67]},{8:1 7,9:5,11:6 ,12:7,13:8 ,14:[1,9], 15:[1,10], 16:[1,12], 19:[1,11], 20:[2,4],2 2:[1,13],2 3:[1,14],2 5:[1,15]}, {18:[2,24] ,24:[2,24] ,36:[2,24] },{18:[2,4 4],24:[2,4 4],32:[2,4 4],33:[2,4 4],34:[2,4 4],35:[2,4 4],36:[2,4 4],40:[2,4 4],42:[2,4 4]},{18:[2 ,46],24:[2 ,46],36:[2 ,46]},{18: [2,26],24: [2,26],32: [2,26],33: [2,26],34: [2,26],35: [2,26],36: [2,26],40: [2,26],42: [2,26]},{1 8:[2,27],2 4:[2,27],3 2:[2,27],3 3:[2,27],3 4:[2,27],3 5:[2,27],3 6:[2,27],4 0:[2,27],4 2:[2,27]}, {18:[2,28] ,24:[2,28] ,32:[2,28] ,33:[2,28] ,34:[2,28] ,35:[2,28] ,36:[2,28] ,40:[2,28] ,42:[2,28] },{18:[2,2 9],24:[2,2 9],32:[2,2 9],33:[2,2 9],34:[2,2 9],35:[2,2 9],36:[2,2 9],40:[2,2 9],42:[2,2 9]},{18:[2 ,30],24:[2 ,30],32:[2 ,30],33:[2 ,30],34:[2 ,30],35:[2 ,30],36:[2 ,30],40:[2 ,30],42:[2 ,30]},{17: 68,21:24,3 0:25,40:[1 ,28],42:[1 ,27],43:26 },{18:[2,3 2],24:[2,3 2],36:[2,3 2],39:69,4 0:[1,70]}, {18:[2,47] ,24:[2,47] ,36:[2,47] ,40:[2,47] },{18:[2,4 0],24:[2,4 0],32:[2,4 0],33:[2,4 0],34:[2,4 0],35:[2,4 0],36:[2,4 0],40:[2,4 0],41:[1,7 1],42:[2,4 0],44:[2,4 0]},{18:[2 ,39],24:[2 ,39],32:[2 ,39],33:[2 ,39],34:[2 ,39],35:[2 ,39],36:[2 ,39],40:[2 ,39],42:[2 ,39],44:[2 ,39]},{5:[ 2,22],14:[ 2,22],15:[ 2,22],16:[ 2,22],19:[ 2,22],20:[ 2,22],22:[ 2,22],23:[ 2,22],25:[ 2,22]},{5: [2,19],14: [2,19],15: [2,19],16: [2,19],19: [2,19],20: [2,19],22: [2,19],23: [2,19],25: [2,19]},{3 6:[1,72]}, {18:[2,48] ,24:[2,48] ,36:[2,48] ,40:[2,48] },{41:[1,7 1]},{21:56 ,30:60,31: 73,32:[1,5 7],33:[1,5 8],34:[1,5 9],35:[1,6 1],40:[1,2 8],42:[1,2 7],43:26}, {18:[2,31] ,24:[2,31] ,32:[2,31] ,33:[2,31] ,34:[2,31] ,35:[2,31] ,36:[2,31] ,40:[2,31] ,42:[2,31] },{18:[2,3 3],24:[2,3 3],36:[2,3 3],40:[2,3 3]}], | |||||
| 869 | defaultA ctions: {3 :[2,2],16: [2,1],50:[ 2,42]}, | |||||
| 870 | parseErr or: functi on parseEr ror(str, h ash) { | |||||
| 871 | thro w new Erro r(str); | |||||
| 872 | }, | |||||
| 873 | parse: f unction pa rse(input) { | |||||
| 874 | var self = thi s, stack = [0], vsta ck = [null ], lstack = [], tabl e = this.t able, yyte xt = "", y ylineno = 0, yyleng = 0, recov ering = 0, TERROR = 2, EOF = 1 ; | |||||
| 875 | this .lexer.set Input(inpu t); | |||||
| 876 | this .lexer.yy = this.yy; | |||||
| 877 | this .yy.lexer = this.lex er; | |||||
| 878 | this .yy.parser = this; | |||||
| 879 | if ( typeof thi s.lexer.yy lloc == "u ndefined") | |||||
| 880 | this.lexer .yylloc = {}; | |||||
| 881 | var yyloc = th is.lexer.y ylloc; | |||||
| 882 | lsta ck.push(yy loc); | |||||
| 883 | var ranges = t his.lexer. options && this.lexe r.options. ranges; | |||||
| 884 | if ( typeof thi s.yy.parse Error === "function" ) | |||||
| 885 | this.parse Error = th is.yy.pars eError; | |||||
| 886 | func tion popSt ack(n) { | |||||
| 887 | stack.leng th = stack .length - 2 * n; | |||||
| 888 | vstack.len gth = vsta ck.length - n; | |||||
| 889 | lstack.len gth = lsta ck.length - n; | |||||
| 890 | } | |||||
| 891 | func tion lex() { | |||||
| 892 | var token; | |||||
| 893 | token = se lf.lexer.l ex() || 1; | |||||
| 894 | if (typeof token !== "number") { | |||||
| 895 | token = self.sym bols_[toke n] || toke n; | |||||
| 896 | } | |||||
| 897 | return tok en; | |||||
| 898 | } | |||||
| 899 | var symbol, pr eErrorSymb ol, state, action, a , r, yyval = {}, p, len, newSt ate, expec ted; | |||||
| 900 | whil e (true) { | |||||
| 901 | state = st ack[stack. length - 1 ]; | |||||
| 902 | if (this.d efaultActi ons[state] ) { | |||||
| 903 | action = this.de faultActio ns[state]; | |||||
| 904 | } else { | |||||
| 905 | if (sy mbol === n ull || typ eof symbol == "undef ined") { | |||||
| 906 | sy mbol = lex (); | |||||
| 907 | } | |||||
| 908 | action = table[s tate] && t able[state ][symbol]; | |||||
| 909 | } | |||||
| 910 | if (typeof action == = "undefin ed" || !ac tion.lengt h || !acti on[0]) { | |||||
| 911 | var er rStr = ""; | |||||
| 912 | if (!r ecovering) { | |||||
| 913 | ex pected = [ ]; | |||||
| 914 | fo r (p in ta ble[state] ) | |||||
| 915 | if (this .terminals _[p] && p > 2) { | |||||
| 916 | expe cted.push( "'" + this .terminals _[p] + "'" ); | |||||
| 917 | } | |||||
| 918 | if (this.lex er.showPos ition) { | |||||
| 919 | errStr = "Parse er ror on lin e " + (yyl ineno + 1) + ":\n" + this.lexe r.showPosi tion() + " \nExpectin g " + expe cted.join( ", ") + ", got '" + (this.term inals_[sym bol] || sy mbol) + "' "; | |||||
| 920 | } else { | |||||
| 921 | errStr = "Parse er ror on lin e " + (yyl ineno + 1) + ": Unex pected " + (symbol = = 1?"end o f input":" '" + (this .terminals _[symbol] || symbol) + "'"); | |||||
| 922 | } | |||||
| 923 | th is.parseEr ror(errStr , {text: t his.lexer. match, tok en: this.t erminals_[ symbol] || symbol, l ine: this. lexer.yyli neno, loc: yyloc, ex pected: ex pected}); | |||||
| 924 | } | |||||
| 925 | } | |||||
| 926 | if (action [0] instan ceof Array && action .length > 1) { | |||||
| 927 | throw new Error( "Parse Err or: multip le actions possible at state: " + state + ", token : " + symb ol); | |||||
| 928 | } | |||||
| 929 | switch (ac tion[0]) { | |||||
| 930 | case 1: | |||||
| 931 | stack. push(symbo l); | |||||
| 932 | vstack .push(this .lexer.yyt ext); | |||||
| 933 | lstack .push(this .lexer.yyl loc); | |||||
| 934 | stack. push(actio n[1]); | |||||
| 935 | symbol = null; | |||||
| 936 | if (!p reErrorSym bol) { | |||||
| 937 | yy leng = thi s.lexer.yy leng; | |||||
| 938 | yy text = thi s.lexer.yy text; | |||||
| 939 | yy lineno = t his.lexer. yylineno; | |||||
| 940 | yy loc = this .lexer.yyl loc; | |||||
| 941 | if (recoveri ng > 0) | |||||
| 942 | recoveri ng--; | |||||
| 943 | } else { | |||||
| 944 | sy mbol = pre ErrorSymbo l; | |||||
| 945 | pr eErrorSymb ol = null; | |||||
| 946 | } | |||||
| 947 | break; | |||||
| 948 | case 2: | |||||
| 949 | len = this.produ ctions_[ac tion[1]][1 ]; | |||||
| 950 | yyval. $ = vstack [vstack.le ngth - len ]; | |||||
| 951 | yyval. _$ = {firs t_line: ls tack[lstac k.length - (len || 1 )].first_l ine, last_ line: lsta ck[lstack. length - 1 ].last_lin e, first_c olumn: lst ack[lstack .length - (len || 1) ].first_co lumn, last _column: l stack[lsta ck.length - 1].last_ column}; | |||||
| 952 | if (ra nges) { | |||||
| 953 | yy val._$.ran ge = [lsta ck[lstack. length - ( len || 1)] .range[0], lstack[ls tack.lengt h - 1].ran ge[1]]; | |||||
| 954 | } | |||||
| 955 | r = th is.perform Action.cal l(yyval, y ytext, yyl eng, yylin eno, this. yy, action [1], vstac k, lstack) ; | |||||
| 956 | if (ty peof r !== "undefine d") { | |||||
| 957 | re turn r; | |||||
| 958 | } | |||||
| 959 | if (le n) { | |||||
| 960 | st ack = stac k.slice(0, -1 * len * 2); | |||||
| 961 | vs tack = vst ack.slice( 0, -1 * le n); | |||||
| 962 | ls tack = lst ack.slice( 0, -1 * le n); | |||||
| 963 | } | |||||
| 964 | stack. push(this. production s_[action[ 1]][0]); | |||||
| 965 | vstack .push(yyva l.$); | |||||
| 966 | lstack .push(yyva l._$); | |||||
| 967 | newSta te = table [stack[sta ck.length - 2]][stac k[stack.le ngth - 1]] ; | |||||
| 968 | stack. push(newSt ate); | |||||
| 969 | break; | |||||
| 970 | case 3: | |||||
| 971 | return true; | |||||
| 972 | } | |||||
| 973 | } | |||||
| 974 | retu rn true; | |||||
| 975 | } | |||||
| 976 | }; | |||||
| 977 | ||||||
| 978 | ||||||
| 979 | function stripFlag s(open, cl ose) { | |||||
| 980 | return { | |||||
| 981 | left : open.cha rAt(2) === '~', | |||||
| 982 | righ t: close.c harAt(0) = == '~' || close.char At(1) === '~' | |||||
| 983 | }; | |||||
| 984 | } | |||||
| 985 | ||||||
| 986 | /* Jison generated lexer */ | |||||
| 987 | var lexe r = (funct ion(){ | |||||
| 988 | var lexe r = ({EOF: 1, | |||||
| 989 | parseErr or:functio n parseErr or(str, ha sh) { | |||||
| 990 | if (this.y y.parser) { | |||||
| 991 | this.y y.parser.p arseError( str, hash) ; | |||||
| 992 | } else { | |||||
| 993 | throw new Error( str); | |||||
| 994 | } | |||||
| 995 | }, | |||||
| 996 | setInput :function (input) { | |||||
| 997 | this._inpu t = input; | |||||
| 998 | this._more = this._l ess = this .done = fa lse; | |||||
| 999 | this.yylin eno = this .yyleng = 0; | |||||
| 1000 | this.yytex t = this.m atched = t his.match = ''; | |||||
| 1001 | this.condi tionStack = ['INITIA L']; | |||||
| 1002 | this.yyllo c = {first _line:1,fi rst_column :0,last_li ne:1,last_ column:0}; | |||||
| 1003 | if (this.o ptions.ran ges) this. yylloc.ran ge = [0,0] ; | |||||
| 1004 | this.offse t = 0; | |||||
| 1005 | return thi s; | |||||
| 1006 | }, | |||||
| 1007 | input:fu nction () { | |||||
| 1008 | var ch = t his._input [0]; | |||||
| 1009 | this.yytex t += ch; | |||||
| 1010 | this.yylen g++; | |||||
| 1011 | this.offse t++; | |||||
| 1012 | this.match += ch; | |||||
| 1013 | this.match ed += ch; | |||||
| 1014 | var lines = ch.match (/(?:\r\n? |\n).*/g); | |||||
| 1015 | if (lines) { | |||||
| 1016 | this.y ylineno++; | |||||
| 1017 | this.y ylloc.last _line++; | |||||
| 1018 | } else { | |||||
| 1019 | this.y ylloc.last _column++; | |||||
| 1020 | } | |||||
| 1021 | if (this.o ptions.ran ges) this. yylloc.ran ge[1]++; | |||||
| 1022 | ||||||
| 1023 | this._inpu t = this._ input.slic e(1); | |||||
| 1024 | return ch; | |||||
| 1025 | }, | |||||
| 1026 | unput:fu nction (ch ) { | |||||
| 1027 | var len = ch.length; | |||||
| 1028 | var lines = ch.split (/(?:\r\n? |\n)/g); | |||||
| 1029 | ||||||
| 1030 | this._inpu t = ch + t his._input ; | |||||
| 1031 | this.yytex t = this.y ytext.subs tr(0, this .yytext.le ngth-len-1 ); | |||||
| 1032 | //this.yyl eng -= len ; | |||||
| 1033 | this.offse t -= len; | |||||
| 1034 | var oldLin es = this. match.spli t(/(?:\r\n ?|\n)/g); | |||||
| 1035 | this.match = this.ma tch.substr (0, this.m atch.lengt h-1); | |||||
| 1036 | this.match ed = this. matched.su bstr(0, th is.matched .length-1) ; | |||||
| 1037 | ||||||
| 1038 | if (lines. length-1) this.yylin eno -= lin es.length- 1; | |||||
| 1039 | var r = th is.yylloc. range; | |||||
| 1040 | ||||||
| 1041 | this.yyllo c = {first _line: thi s.yylloc.f irst_line, | |||||
| 1042 | last_lin e: this.yy lineno+1, | |||||
| 1043 | first_co lumn: this .yylloc.fi rst_column , | |||||
| 1044 | last_col umn: lines ? | |||||
| 1045 | (lin es.length === oldLin es.length ? this.yyl loc.first_ column : 0 ) + oldLin es[oldLine s.length - lines.len gth].lengt h - lines[ 0].length: | |||||
| 1046 | this .yylloc.fi rst_column - len | |||||
| 1047 | }; | |||||
| 1048 | ||||||
| 1049 | if (this.o ptions.ran ges) { | |||||
| 1050 | this.y ylloc.rang e = [r[0], r[0] + th is.yyleng - len]; | |||||
| 1051 | } | |||||
| 1052 | return thi s; | |||||
| 1053 | }, | |||||
| 1054 | more:fun ction () { | |||||
| 1055 | this._more = true; | |||||
| 1056 | return thi s; | |||||
| 1057 | }, | |||||
| 1058 | less:fun ction (n) { | |||||
| 1059 | this.unput (this.matc h.slice(n) ); | |||||
| 1060 | }, | |||||
| 1061 | pastInpu t:function () { | |||||
| 1062 | var past = this.matc hed.substr (0, this.m atched.len gth - this .match.len gth); | |||||
| 1063 | return (pa st.length > 20 ? '.. .':'') + p ast.substr (-20).repl ace(/\n/g, ""); | |||||
| 1064 | }, | |||||
| 1065 | upcoming Input:func tion () { | |||||
| 1066 | var next = this.matc h; | |||||
| 1067 | if (next.l ength < 20 ) { | |||||
| 1068 | next + = this._in put.substr (0, 20-nex t.length); | |||||
| 1069 | } | |||||
| 1070 | return (ne xt.substr( 0,20)+(nex t.length > 20 ? '... ':'')).rep lace(/\n/g , ""); | |||||
| 1071 | }, | |||||
| 1072 | showPosi tion:funct ion () { | |||||
| 1073 | var pre = this.pastI nput(); | |||||
| 1074 | var c = ne w Array(pr e.length + 1).join(" -"); | |||||
| 1075 | return pre + this.up comingInpu t() + "\n" + c+"^"; | |||||
| 1076 | }, | |||||
| 1077 | next:fun ction () { | |||||
| 1078 | if (this.d one) { | |||||
| 1079 | return this.EOF; | |||||
| 1080 | } | |||||
| 1081 | if (!this. _input) th is.done = true; | |||||
| 1082 | ||||||
| 1083 | var token, | |||||
| 1084 | match, | |||||
| 1085 | tempMa tch, | |||||
| 1086 | index, | |||||
| 1087 | col, | |||||
| 1088 | lines; | |||||
| 1089 | if (!this. _more) { | |||||
| 1090 | this.y ytext = '' ; | |||||
| 1091 | this.m atch = ''; | |||||
| 1092 | } | |||||
| 1093 | var rules = this._cu rrentRules (); | |||||
| 1094 | for (var i =0;i < rul es.length; i++) { | |||||
| 1095 | tempMa tch = this ._input.ma tch(this.r ules[rules [i]]); | |||||
| 1096 | if (te mpMatch && (!match | | tempMatc h[0].lengt h > match[ 0].length) ) { | |||||
| 1097 | ma tch = temp Match; | |||||
| 1098 | in dex = i; | |||||
| 1099 | if (!this.op tions.flex ) break; | |||||
| 1100 | } | |||||
| 1101 | } | |||||
| 1102 | if (match) { | |||||
| 1103 | lines = match[0] .match(/(? :\r\n?|\n) .*/g); | |||||
| 1104 | if (li nes) this. yylineno + = lines.le ngth; | |||||
| 1105 | this.y ylloc = {f irst_line: this.yyll oc.last_li ne, | |||||
| 1106 | l ast_line: this.yylin eno+1, | |||||
| 1107 | f irst_colum n: this.yy lloc.last_ column, | |||||
| 1108 | l ast_column : lines ? lines[line s.length-1 ].length-l ines[lines .length-1] .match(/\r ?\n?/)[0]. length : t his.yylloc .last_colu mn + match [0].length }; | |||||
| 1109 | this.y ytext += m atch[0]; | |||||
| 1110 | this.m atch += ma tch[0]; | |||||
| 1111 | this.m atches = m atch; | |||||
| 1112 | this.y yleng = th is.yytext. length; | |||||
| 1113 | if (th is.options .ranges) { | |||||
| 1114 | th is.yylloc. range = [t his.offset , this.off set += thi s.yyleng]; | |||||
| 1115 | } | |||||
| 1116 | this._ more = fal se; | |||||
| 1117 | this._ input = th is._input. slice(matc h[0].lengt h); | |||||
| 1118 | this.m atched += match[0]; | |||||
| 1119 | token = this.per formAction .call(this , this.yy, this, rul es[index], this.condi tionStack[ this.condi tionStack. length-1]) ; | |||||
| 1120 | if (th is.done && this._inp ut) this.d one = fals e; | |||||
| 1121 | if (to ken) retur n token; | |||||
| 1122 | else r eturn; | |||||
| 1123 | } | |||||
| 1124 | if (this._ input === "") { | |||||
| 1125 | return this.EOF; | |||||
| 1126 | } else { | |||||
| 1127 | return this.pars eError('Le xical erro r on line '+(this.yy lineno+1)+ '. Unrecog nized text .\n'+this. showPositi on(), | |||||
| 1128 | {text: " ", token: null, line : this.yyl ineno}); | |||||
| 1129 | } | |||||
| 1130 | }, | |||||
| 1131 | lex:func tion lex() { | |||||
| 1132 | var r = th is.next(); | |||||
| 1133 | if (typeof r !== 'un defined') { | |||||
| 1134 | return r; | |||||
| 1135 | } else { | |||||
| 1136 | return this.lex( ); | |||||
| 1137 | } | |||||
| 1138 | }, | |||||
| 1139 | begin:fu nction beg in(conditi on) { | |||||
| 1140 | this.condi tionStack. push(condi tion); | |||||
| 1141 | }, | |||||
| 1142 | popState :function popState() { | |||||
| 1143 | return thi s.conditio nStack.pop (); | |||||
| 1144 | }, | |||||
| 1145 | _current Rules:func tion _curr entRules() { | |||||
| 1146 | return thi s.conditio ns[this.co nditionSta ck[this.co nditionSta ck.length- 1]].rules; | |||||
| 1147 | }, | |||||
| 1148 | topState :function () { | |||||
| 1149 | return thi s.conditio nStack[thi s.conditio nStack.len gth-2]; | |||||
| 1150 | }, | |||||
| 1151 | pushStat e:function begin(con dition) { | |||||
| 1152 | this.begin (condition ); | |||||
| 1153 | }}); | |||||
| 1154 | lexer.op tions = {} ; | |||||
| 1155 | lexer.pe rformActio n = functi on anonymo us(yy,yy_, $avoiding_ name_colli sions,YY_S TART) { | |||||
| 1156 | ||||||
| 1157 | ||||||
| 1158 | function strip(sta rt, end) { | |||||
| 1159 | return yy_.yytex t = yy_.yy text.subst r(start, y y_.yyleng- end); | |||||
| 1160 | } | |||||
| 1161 | ||||||
| 1162 | ||||||
| 1163 | var YYST ATE=YY_STA RT | |||||
| 1164 | switch($ avoiding_n ame_collis ions) { | |||||
| 1165 | case 0: | |||||
| 1166 | if( yy_.yytext .slice(-2) === "\\\\ ") { | |||||
| 1167 | s trip(0,1); | |||||
| 1168 | t his.begin( "mu"); | |||||
| 1169 | } e lse if(yy_ .yytext.sl ice(-1) == = "\\") { | |||||
| 1170 | s trip(0,1); | |||||
| 1171 | t his.begin( "emu"); | |||||
| 1172 | } e lse { | |||||
| 1173 | t his.begin( "mu"); | |||||
| 1174 | } | |||||
| 1175 | if( yy_.yytext ) return 1 4; | |||||
| 1176 | ||||||
| 1177 | break; | |||||
| 1178 | case 1:r eturn 14; | |||||
| 1179 | break; | |||||
| 1180 | case 2: | |||||
| 1181 | thi s.popState (); | |||||
| 1182 | ret urn 14; | |||||
| 1183 | ||||||
| 1184 | break; | |||||
| 1185 | case 3:s trip(0,4); this.popS tate(); re turn 15; | |||||
| 1186 | break; | |||||
| 1187 | case 4:r eturn 35; | |||||
| 1188 | break; | |||||
| 1189 | case 5:r eturn 36; | |||||
| 1190 | break; | |||||
| 1191 | case 6:r eturn 25; | |||||
| 1192 | break; | |||||
| 1193 | case 7:r eturn 16; | |||||
| 1194 | break; | |||||
| 1195 | case 8:r eturn 20; | |||||
| 1196 | break; | |||||
| 1197 | case 9:r eturn 19; | |||||
| 1198 | break; | |||||
| 1199 | case 10: return 19; | |||||
| 1200 | break; | |||||
| 1201 | case 11: return 23; | |||||
| 1202 | break; | |||||
| 1203 | case 12: return 22; | |||||
| 1204 | break; | |||||
| 1205 | case 13: this.popSt ate(); thi s.begin('c om'); | |||||
| 1206 | break; | |||||
| 1207 | case 14: strip(3,5) ; this.pop State(); r eturn 15; | |||||
| 1208 | break; | |||||
| 1209 | case 15: return 22; | |||||
| 1210 | break; | |||||
| 1211 | case 16: return 41; | |||||
| 1212 | break; | |||||
| 1213 | case 17: return 40; | |||||
| 1214 | break; | |||||
| 1215 | case 18: return 40; | |||||
| 1216 | break; | |||||
| 1217 | case 19: return 44; | |||||
| 1218 | break; | |||||
| 1219 | case 20: // ignore whitespace | |||||
| 1220 | break; | |||||
| 1221 | case 21: this.popSt ate(); ret urn 24; | |||||
| 1222 | break; | |||||
| 1223 | case 22: this.popSt ate(); ret urn 18; | |||||
| 1224 | break; | |||||
| 1225 | case 23: yy_.yytext = strip(1 ,2).replac e(/\\"/g,' "'); retur n 32; | |||||
| 1226 | break; | |||||
| 1227 | case 24: yy_.yytext = strip(1 ,2).replac e(/\\'/g," '"); retur n 32; | |||||
| 1228 | break; | |||||
| 1229 | case 25: return 42; | |||||
| 1230 | break; | |||||
| 1231 | case 26: return 34; | |||||
| 1232 | break; | |||||
| 1233 | case 27: return 34; | |||||
| 1234 | break; | |||||
| 1235 | case 28: return 33; | |||||
| 1236 | break; | |||||
| 1237 | case 29: return 40; | |||||
| 1238 | break; | |||||
| 1239 | case 30: yy_.yytext = strip(1 ,2); retur n 40; | |||||
| 1240 | break; | |||||
| 1241 | case 31: return 'IN VALID'; | |||||
| 1242 | break; | |||||
| 1243 | case 32: return 5; | |||||
| 1244 | break; | |||||
| 1245 | } | |||||
| 1246 | }; | |||||
| 1247 | lexer.ru les = [/^( ?:[^\x00]* ?(?=(\{\{) ))/,/^(?:[ ^\x00]+)/, /^(?:[^\x0 0]{2,}?(?= (\{\{|\\\{ \{|\\\\\{\ {|$)))/,/^ (?:[\s\S]* ?--\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{( ~)?>)/,/^( ?:\{\{(~)? #)/,/^(?:\ {\{(~)?\/) /,/^(?:\{\ {(~)?\^)/, /^(?:\{\{( ~)?\s*else \b)/,/^(?: \{\{(~)?\{ )/,/^(?:\{ \{(~)?&)/, /^(?:\{\{! --)/,/^(?: \{\{![\s\S ]*?\}\})/, /^(?:\{\{( ~)?)/,/^(? :=)/,/^(?: \.\.)/,/^( ?:\.(?=([= ~}\s\/.)]) ))/,/^(?:[ \/.])/,/^( ?:\s+)/,/^ (?:\}(~)?\ }\})/,/^(? :(~)?\}\}) /,/^(?:"(\ \["]|[^"]) *")/,/^(?: '(\\[']|[^ '])*')/,/^ (?:@)/,/^( ?:true(?=( [~}\s)]))) /,/^(?:fal se(?=([~}\ s)])))/,/^ (?:-?[0-9] +(?=([~}\s )])))/,/^( ?:([^\s!"# %-,\.\/;-> @\[-\^`\{- ~]+(?=([=~ }\s\/.)])) ))/,/^(?:\ [[^\]]*\]) /,/^(?:.)/ ,/^(?:$)/] ; | |||||
| 1248 | lexer.co nditions = {"mu":{"r ules":[4,5 ,6,7,8,9,1 0,11,12,13 ,14,15,16, 17,18,19,2 0,21,22,23 ,24,25,26, 27,28,29,3 0,31,32]," inclusive" :false},"e mu":{"rule s":[2],"in clusive":f alse},"com ":{"rules" :[3],"incl usive":fal se},"INITI AL":{"rule s":[0,1,32 ],"inclusi ve":true}} ; | |||||
| 1249 | return l exer;})() | |||||
| 1250 | parser.l exer = lex er; | |||||
| 1251 | function Parser () { this.yy = {}; }Pa rser.proto type = par ser;parser .Parser = Parser; | |||||
| 1252 | return n ew Parser; | |||||
| 1253 | })();__e xports__ = handlebar s; | |||||
| 1254 | /* jshin t ignore:e nd */ | |||||
| 1255 | return _ _exports__ ; | |||||
| 1256 | })(); | |||||
| 1257 | ||||||
| 1258 | // handleb ars/compil er/base.js | |||||
| 1259 | var __modu le8__ = (f unction(__ dependency 1__, __dep endency2__ ) { | |||||
| 1260 | "use str ict"; | |||||
| 1261 | var __ex ports__ = {}; | |||||
| 1262 | var pars er = __dep endency1__ ; | |||||
| 1263 | var AST = __depend ency2__; | |||||
| 1264 | ||||||
| 1265 | __export s__.parser = parser; | |||||
| 1266 | ||||||
| 1267 | function parse(inp ut) { | |||||
| 1268 | // Jus t return i f an alrea dy-compile AST was p assed in. | |||||
| 1269 | if(inp ut.constru ctor === A ST.Program Node) { re turn input ; } | |||||
| 1270 | ||||||
| 1271 | parser .yy = AST; | |||||
| 1272 | return parser.pa rse(input) ; | |||||
| 1273 | } | |||||
| 1274 | ||||||
| 1275 | __export s__.parse = parse; | |||||
| 1276 | return _ _exports__ ; | |||||
| 1277 | })(__modul e9__, __mo dule7__); | |||||
| 1278 | ||||||
| 1279 | // handleb ars/compil er/compile r.js | |||||
| 1280 | var __modu le10__ = ( function(_ _dependenc y1__) { | |||||
| 1281 | "use str ict"; | |||||
| 1282 | var __ex ports__ = {}; | |||||
| 1283 | var Exce ption = __ dependency 1__; | |||||
| 1284 | ||||||
| 1285 | function Compiler( ) {} | |||||
| 1286 | ||||||
| 1287 | __export s__.Compil er = Compi ler;// the foundHelp er registe r will dis ambiguate helper loo kup from f inding a | |||||
| 1288 | // funct ion in a c ontext. Th is is nece ssary for mustache c ompatibili ty, which | |||||
| 1289 | // requi res that c ontext fun ctions in blocks are evaluated by blockH elperMissi ng, | |||||
| 1290 | // and t hen procee d as if th e resultin g value wa s provided to blockH elperMissi ng. | |||||
| 1291 | ||||||
| 1292 | Compiler .prototype = { | |||||
| 1293 | compil er: Compil er, | |||||
| 1294 | ||||||
| 1295 | disass emble: fun ction() { | |||||
| 1296 | var opcodes = this.opcod es, opcode , out = [] , params, param; | |||||
| 1297 | ||||||
| 1298 | for (var i=0, l=opcodes. length; i< l; i++) { | |||||
| 1299 | op code = opc odes[i]; | |||||
| 1300 | ||||||
| 1301 | if (opcode.o pcode === 'DECLARE') { | |||||
| 1302 | out.push(" DECLARE " + opcode.n ame + "=" + opcode.v alue); | |||||
| 1303 | } else { | |||||
| 1304 | params = [ ]; | |||||
| 1305 | for (var j =0; j<opco de.args.le ngth; j++) { | |||||
| 1306 | param = opcode.arg s[j]; | |||||
| 1307 | if (type of param = == "string ") { | |||||
| 1308 | param = "\"" + p aram.repla ce("\n", " \\n") + "\ ""; | |||||
| 1309 | } | |||||
| 1310 | params.p ush(param) ; | |||||
| 1311 | } | |||||
| 1312 | out.push(o pcode.opco de + " " + params.jo in(" ")); | |||||
| 1313 | } | |||||
| 1314 | } | |||||
| 1315 | ||||||
| 1316 | retu rn out.joi n("\n"); | |||||
| 1317 | }, | |||||
| 1318 | ||||||
| 1319 | equals : function (other) { | |||||
| 1320 | var len = this .opcodes.l ength; | |||||
| 1321 | if ( other.opco des.length !== len) { | |||||
| 1322 | re turn false ; | |||||
| 1323 | } | |||||
| 1324 | ||||||
| 1325 | for (var i = 0 ; i < len; i++) { | |||||
| 1326 | va r opcode = this.opco des[i], | |||||
| 1327 | otherOpc ode = othe r.opcodes[ i]; | |||||
| 1328 | if (opcode.o pcode !== otherOpcod e.opcode | | opcode.a rgs.length !== other Opcode.arg s.length) { | |||||
| 1329 | return fal se; | |||||
| 1330 | } | |||||
| 1331 | fo r (var j = 0; j < op code.args. length; j+ +) { | |||||
| 1332 | if (opcode .args[j] ! == otherOp code.args[ j]) { | |||||
| 1333 | return f alse; | |||||
| 1334 | } | |||||
| 1335 | } | |||||
| 1336 | } | |||||
| 1337 | ||||||
| 1338 | len = this.chi ldren.leng th; | |||||
| 1339 | if ( other.chil dren.lengt h !== len) { | |||||
| 1340 | re turn false ; | |||||
| 1341 | } | |||||
| 1342 | for (i = 0; i < len; i++ ) { | |||||
| 1343 | if (!this.ch ildren[i]. equals(oth er.childre n[i])) { | |||||
| 1344 | return fal se; | |||||
| 1345 | } | |||||
| 1346 | } | |||||
| 1347 | ||||||
| 1348 | retu rn true; | |||||
| 1349 | }, | |||||
| 1350 | ||||||
| 1351 | guid: 0, | |||||
| 1352 | ||||||
| 1353 | compil e: functio n(program, options) { | |||||
| 1354 | this .opcodes = []; | |||||
| 1355 | this .children = []; | |||||
| 1356 | this .depths = {list: []} ; | |||||
| 1357 | this .options = options; | |||||
| 1358 | ||||||
| 1359 | // T hese chang es will pr opagate to the other compiler components | |||||
| 1360 | var knownHelpe rs = this. options.kn ownHelpers ; | |||||
| 1361 | this .options.k nownHelper s = { | |||||
| 1362 | 'h elperMissi ng': true, | |||||
| 1363 | 'b lockHelper Missing': true, | |||||
| 1364 | 'e ach': true , | |||||
| 1365 | 'i f': true, | |||||
| 1366 | 'u nless': tr ue, | |||||
| 1367 | 'w ith': true , | |||||
| 1368 | 'l og': true | |||||
| 1369 | }; | |||||
| 1370 | if ( knownHelpe rs) { | |||||
| 1371 | fo r (var nam e in known Helpers) { | |||||
| 1372 | this.optio ns.knownHe lpers[name ] = knownH elpers[nam e]; | |||||
| 1373 | } | |||||
| 1374 | } | |||||
| 1375 | ||||||
| 1376 | retu rn this.ac cept(progr am); | |||||
| 1377 | }, | |||||
| 1378 | ||||||
| 1379 | accept : function (node) { | |||||
| 1380 | var strip = no de.strip | | {}, | |||||
| 1381 | ret; | |||||
| 1382 | if ( strip.left ) { | |||||
| 1383 | th is.opcode( 'strip'); | |||||
| 1384 | } | |||||
| 1385 | ||||||
| 1386 | ret = this[nod e.type](no de); | |||||
| 1387 | ||||||
| 1388 | if ( strip.righ t) { | |||||
| 1389 | th is.opcode( 'strip'); | |||||
| 1390 | } | |||||
| 1391 | ||||||
| 1392 | retu rn ret; | |||||
| 1393 | }, | |||||
| 1394 | ||||||
| 1395 | progra m: functio n(program) { | |||||
| 1396 | var statements = program .statement s; | |||||
| 1397 | ||||||
| 1398 | for( var i=0, l =statement s.length; i<l; i++) { | |||||
| 1399 | th is.accept( statements [i]); | |||||
| 1400 | } | |||||
| 1401 | this .isSimple = l === 1; | |||||
| 1402 | ||||||
| 1403 | this .depths.li st = this. depths.lis t.sort(fun ction(a, b ) { | |||||
| 1404 | re turn a - b ; | |||||
| 1405 | }); | |||||
| 1406 | ||||||
| 1407 | retu rn this; | |||||
| 1408 | }, | |||||
| 1409 | ||||||
| 1410 | compil eProgram: function(p rogram) { | |||||
| 1411 | var result = n ew this.co mpiler().c ompile(pro gram, this .options); | |||||
| 1412 | var guid = thi s.guid++, depth; | |||||
| 1413 | ||||||
| 1414 | this .usePartia l = this.u sePartial || result. usePartial ; | |||||
| 1415 | ||||||
| 1416 | this .children[ guid] = re sult; | |||||
| 1417 | ||||||
| 1418 | for( var i=0, l =result.de pths.list. length; i< l; i++) { | |||||
| 1419 | de pth = resu lt.depths. list[i]; | |||||
| 1420 | ||||||
| 1421 | if (depth < 2 ) { contin ue; } | |||||
| 1422 | el se { this. addDepth(d epth - 1); } | |||||
| 1423 | } | |||||
| 1424 | ||||||
| 1425 | retu rn guid; | |||||
| 1426 | }, | |||||
| 1427 | ||||||
| 1428 | block: function( block) { | |||||
| 1429 | var mustache = block.mus tache, | |||||
| 1430 | program = block.prog ram, | |||||
| 1431 | inverse = block.inve rse; | |||||
| 1432 | ||||||
| 1433 | if ( program) { | |||||
| 1434 | pr ogram = th is.compile Program(pr ogram); | |||||
| 1435 | } | |||||
| 1436 | ||||||
| 1437 | if ( inverse) { | |||||
| 1438 | in verse = th is.compile Program(in verse); | |||||
| 1439 | } | |||||
| 1440 | ||||||
| 1441 | var sexpr = mu stache.sex pr; | |||||
| 1442 | var type = thi s.classify Sexpr(sexp r); | |||||
| 1443 | ||||||
| 1444 | if ( type === " helper") { | |||||
| 1445 | th is.helperS expr(sexpr , program, inverse); | |||||
| 1446 | } el se if (typ e === "sim ple") { | |||||
| 1447 | th is.simpleS expr(sexpr ); | |||||
| 1448 | ||||||
| 1449 | // now that the simple mustache is resolve d, we need to | |||||
| 1450 | // evaluate it by exec uting `blo ckHelperMi ssing` | |||||
| 1451 | th is.opcode( 'pushProgr am', progr am); | |||||
| 1452 | th is.opcode( 'pushProgr am', inver se); | |||||
| 1453 | th is.opcode( 'emptyHash '); | |||||
| 1454 | th is.opcode( 'blockValu e'); | |||||
| 1455 | } el se { | |||||
| 1456 | th is.ambiguo usSexpr(se xpr, progr am, invers e); | |||||
| 1457 | ||||||
| 1458 | // now that the simple mustache is resolve d, we need to | |||||
| 1459 | // evaluate it by exec uting `blo ckHelperMi ssing` | |||||
| 1460 | th is.opcode( 'pushProgr am', progr am); | |||||
| 1461 | th is.opcode( 'pushProgr am', inver se); | |||||
| 1462 | th is.opcode( 'emptyHash '); | |||||
| 1463 | th is.opcode( 'ambiguous BlockValue '); | |||||
| 1464 | } | |||||
| 1465 | ||||||
| 1466 | this .opcode('a ppend'); | |||||
| 1467 | }, | |||||
| 1468 | ||||||
| 1469 | hash: function(h ash) { | |||||
| 1470 | var pairs = ha sh.pairs, pair, val; | |||||
| 1471 | ||||||
| 1472 | this .opcode('p ushHash'); | |||||
| 1473 | ||||||
| 1474 | for( var i=0, l =pairs.len gth; i<l; i++) { | |||||
| 1475 | pa ir = pairs [i]; | |||||
| 1476 | va l = pair[ 1]; | |||||
| 1477 | ||||||
| 1478 | if (this.opt ions.strin gParams) { | |||||
| 1479 | if(val.dep th) { | |||||
| 1480 | this.add Depth(val. depth); | |||||
| 1481 | } | |||||
| 1482 | this.opcod e('getCont ext', val. depth || 0 ); | |||||
| 1483 | this.opcod e('pushStr ingParam', val.strin gModeValue , val.type ); | |||||
| 1484 | ||||||
| 1485 | if (val.ty pe === 'se xpr') { | |||||
| 1486 | // Subex pressions get evalua ted and pa ssed in | |||||
| 1487 | // in st ring param s mode. | |||||
| 1488 | this.sex pr(val); | |||||
| 1489 | } | |||||
| 1490 | } else { | |||||
| 1491 | this.accep t(val); | |||||
| 1492 | } | |||||
| 1493 | ||||||
| 1494 | th is.opcode( 'assignToH ash', pair [0]); | |||||
| 1495 | } | |||||
| 1496 | this .opcode('p opHash'); | |||||
| 1497 | }, | |||||
| 1498 | ||||||
| 1499 | partia l: functio n(partial) { | |||||
| 1500 | var partialNam e = partia l.partialN ame; | |||||
| 1501 | this .usePartia l = true; | |||||
| 1502 | ||||||
| 1503 | if(p artial.con text) { | |||||
| 1504 | th is.ID(part ial.contex t); | |||||
| 1505 | } el se { | |||||
| 1506 | th is.opcode( 'push', 'd epth0'); | |||||
| 1507 | } | |||||
| 1508 | ||||||
| 1509 | this .opcode('i nvokeParti al', parti alName.nam e); | |||||
| 1510 | this .opcode('a ppend'); | |||||
| 1511 | }, | |||||
| 1512 | ||||||
| 1513 | conten t: functio n(content) { | |||||
| 1514 | this .opcode('a ppendConte nt', conte nt.string) ; | |||||
| 1515 | }, | |||||
| 1516 | ||||||
| 1517 | mustac he: functi on(mustach e) { | |||||
| 1518 | this .sexpr(mus tache.sexp r); | |||||
| 1519 | ||||||
| 1520 | if(m ustache.es caped && ! this.optio ns.noEscap e) { | |||||
| 1521 | th is.opcode( 'appendEsc aped'); | |||||
| 1522 | } el se { | |||||
| 1523 | th is.opcode( 'append'); | |||||
| 1524 | } | |||||
| 1525 | }, | |||||
| 1526 | ||||||
| 1527 | ambigu ousSexpr: function(s expr, prog ram, inver se) { | |||||
| 1528 | var id = sexpr .id, | |||||
| 1529 | name = id. parts[0], | |||||
| 1530 | isBlock = program != null || i nverse != null; | |||||
| 1531 | ||||||
| 1532 | this .opcode('g etContext' , id.depth ); | |||||
| 1533 | ||||||
| 1534 | this .opcode('p ushProgram ', program ); | |||||
| 1535 | this .opcode('p ushProgram ', inverse ); | |||||
| 1536 | ||||||
| 1537 | this .opcode('i nvokeAmbig uous', nam e, isBlock ); | |||||
| 1538 | }, | |||||
| 1539 | ||||||
| 1540 | simple Sexpr: fun ction(sexp r) { | |||||
| 1541 | var id = sexpr .id; | |||||
| 1542 | ||||||
| 1543 | if ( id.type == = 'DATA') { | |||||
| 1544 | th is.DATA(id ); | |||||
| 1545 | } el se if (id. parts.leng th) { | |||||
| 1546 | th is.ID(id); | |||||
| 1547 | } el se { | |||||
| 1548 | // Simplifie d ID for ` this` | |||||
| 1549 | th is.addDept h(id.depth ); | |||||
| 1550 | th is.opcode( 'getContex t', id.dep th); | |||||
| 1551 | th is.opcode( 'pushConte xt'); | |||||
| 1552 | } | |||||
| 1553 | ||||||
| 1554 | this .opcode('r esolvePoss ibleLambda '); | |||||
| 1555 | }, | |||||
| 1556 | ||||||
| 1557 | helper Sexpr: fun ction(sexp r, program , inverse) { | |||||
| 1558 | var params = t his.setupF ullMustach eParams(se xpr, progr am, invers e), | |||||
| 1559 | name = sex pr.id.part s[0]; | |||||
| 1560 | ||||||
| 1561 | if ( this.optio ns.knownHe lpers[name ]) { | |||||
| 1562 | th is.opcode( 'invokeKno wnHelper', params.le ngth, name ); | |||||
| 1563 | } el se if (thi s.options. knownHelpe rsOnly) { | |||||
| 1564 | th row new Ex ception("Y ou specifi ed knownHe lpersOnly, but used the unknow n helper " + name, s expr); | |||||
| 1565 | } el se { | |||||
| 1566 | th is.opcode( 'invokeHel per', para ms.length, name, sex pr.isRoot) ; | |||||
| 1567 | } | |||||
| 1568 | }, | |||||
| 1569 | ||||||
| 1570 | sexpr: function( sexpr) { | |||||
| 1571 | var type = thi s.classify Sexpr(sexp r); | |||||
| 1572 | ||||||
| 1573 | if ( type === " simple") { | |||||
| 1574 | th is.simpleS expr(sexpr ); | |||||
| 1575 | } el se if (typ e === "hel per") { | |||||
| 1576 | th is.helperS expr(sexpr ); | |||||
| 1577 | } el se { | |||||
| 1578 | th is.ambiguo usSexpr(se xpr); | |||||
| 1579 | } | |||||
| 1580 | }, | |||||
| 1581 | ||||||
| 1582 | ID: fu nction(id) { | |||||
| 1583 | this .addDepth( id.depth); | |||||
| 1584 | this .opcode('g etContext' , id.depth ); | |||||
| 1585 | ||||||
| 1586 | var name = id. parts[0]; | |||||
| 1587 | if ( !name) { | |||||
| 1588 | th is.opcode( 'pushConte xt'); | |||||
| 1589 | } el se { | |||||
| 1590 | th is.opcode( 'lookupOnC ontext', i d.parts[0] ); | |||||
| 1591 | } | |||||
| 1592 | ||||||
| 1593 | for( var i=1, l =id.parts. length; i< l; i++) { | |||||
| 1594 | th is.opcode( 'lookup', id.parts[i ]); | |||||
| 1595 | } | |||||
| 1596 | }, | |||||
| 1597 | ||||||
| 1598 | DATA: function(d ata) { | |||||
| 1599 | this .options.d ata = true ; | |||||
| 1600 | if ( data.id.is Scoped || data.id.de pth) { | |||||
| 1601 | th row new Ex ception('S coped data reference s are not supported: ' + data. original, data); | |||||
| 1602 | } | |||||
| 1603 | ||||||
| 1604 | this .opcode('l ookupData' ); | |||||
| 1605 | var parts = da ta.id.part s; | |||||
| 1606 | for( var i=0, l =parts.len gth; i<l; i++) { | |||||
| 1607 | th is.opcode( 'lookup', parts[i]); | |||||
| 1608 | } | |||||
| 1609 | }, | |||||
| 1610 | ||||||
| 1611 | STRING : function (string) { | |||||
| 1612 | this .opcode('p ushString' , string.s tring); | |||||
| 1613 | }, | |||||
| 1614 | ||||||
| 1615 | INTEGE R: functio n(integer) { | |||||
| 1616 | this .opcode('p ushLiteral ', integer .integer); | |||||
| 1617 | }, | |||||
| 1618 | ||||||
| 1619 | BOOLEA N: functio n(bool) { | |||||
| 1620 | this .opcode('p ushLiteral ', bool.bo ol); | |||||
| 1621 | }, | |||||
| 1622 | ||||||
| 1623 | commen t: functio n() {}, | |||||
| 1624 | ||||||
| 1625 | // HEL PERS | |||||
| 1626 | opcode : function (name) { | |||||
| 1627 | this .opcodes.p ush({ opco de: name, args: [].s lice.call( arguments, 1) }); | |||||
| 1628 | }, | |||||
| 1629 | ||||||
| 1630 | declar e: functio n(name, va lue) { | |||||
| 1631 | this .opcodes.p ush({ opco de: 'DECLA RE', name: name, val ue: value }); | |||||
| 1632 | }, | |||||
| 1633 | ||||||
| 1634 | addDep th: functi on(depth) { | |||||
| 1635 | if(d epth === 0 ) { return ; } | |||||
| 1636 | ||||||
| 1637 | if(! this.depth s[depth]) { | |||||
| 1638 | th is.depths[ depth] = t rue; | |||||
| 1639 | th is.depths. list.push( depth); | |||||
| 1640 | } | |||||
| 1641 | }, | |||||
| 1642 | ||||||
| 1643 | classi fySexpr: f unction(se xpr) { | |||||
| 1644 | var isHelper = sexpr.i sHelper; | |||||
| 1645 | var isEligible = sexpr.e ligibleHel per; | |||||
| 1646 | var options = this.op tions; | |||||
| 1647 | ||||||
| 1648 | // i f ambiguou s, we can possibly r esolve the ambiguity now | |||||
| 1649 | if ( isEligible && !isHel per) { | |||||
| 1650 | va r name = s expr.id.pa rts[0]; | |||||
| 1651 | ||||||
| 1652 | if (options. knownHelpe rs[name]) { | |||||
| 1653 | isHelper = true; | |||||
| 1654 | } else if (o ptions.kno wnHelpersO nly) { | |||||
| 1655 | isEligible = false; | |||||
| 1656 | } | |||||
| 1657 | } | |||||
| 1658 | ||||||
| 1659 | if ( isHelper) { return " helper"; } | |||||
| 1660 | else if (isEli gible) { r eturn "amb iguous"; } | |||||
| 1661 | else { return "simple"; } | |||||
| 1662 | }, | |||||
| 1663 | ||||||
| 1664 | pushPa rams: func tion(param s) { | |||||
| 1665 | var i = params .length, p aram; | |||||
| 1666 | ||||||
| 1667 | whil e(i--) { | |||||
| 1668 | pa ram = para ms[i]; | |||||
| 1669 | ||||||
| 1670 | if (this.opti ons.string Params) { | |||||
| 1671 | if(param.d epth) { | |||||
| 1672 | this.add Depth(para m.depth); | |||||
| 1673 | } | |||||
| 1674 | ||||||
| 1675 | this.opcod e('getCont ext', para m.depth || 0); | |||||
| 1676 | this.opcod e('pushStr ingParam', param.str ingModeVal ue, param. type); | |||||
| 1677 | ||||||
| 1678 | if (param. type === ' sexpr') { | |||||
| 1679 | // Subex pressions get evalua ted and pa ssed in | |||||
| 1680 | // in st ring param s mode. | |||||
| 1681 | this.sex pr(param); | |||||
| 1682 | } | |||||
| 1683 | } else { | |||||
| 1684 | this[param .type](par am); | |||||
| 1685 | } | |||||
| 1686 | } | |||||
| 1687 | }, | |||||
| 1688 | ||||||
| 1689 | setupF ullMustach eParams: f unction(se xpr, progr am, invers e) { | |||||
| 1690 | var params = s expr.param s; | |||||
| 1691 | this .pushParam s(params); | |||||
| 1692 | ||||||
| 1693 | this .opcode('p ushProgram ', program ); | |||||
| 1694 | this .opcode('p ushProgram ', inverse ); | |||||
| 1695 | ||||||
| 1696 | if ( sexpr.hash ) { | |||||
| 1697 | th is.hash(se xpr.hash); | |||||
| 1698 | } el se { | |||||
| 1699 | th is.opcode( 'emptyHash '); | |||||
| 1700 | } | |||||
| 1701 | ||||||
| 1702 | retu rn params; | |||||
| 1703 | } | |||||
| 1704 | }; | |||||
| 1705 | ||||||
| 1706 | function precompil e(input, o ptions, en v) { | |||||
| 1707 | if (in put == nul l || (type of input ! == 'string ' && input .construct or !== env .AST.Progr amNode)) { | |||||
| 1708 | thro w new Exce ption("You must pass a string or Handleb ars AST to Handlebar s.precompi le. You pa ssed " + i nput); | |||||
| 1709 | } | |||||
| 1710 | ||||||
| 1711 | option s = option s || {}; | |||||
| 1712 | if (!( 'data' in options)) { | |||||
| 1713 | opti ons.data = true; | |||||
| 1714 | } | |||||
| 1715 | ||||||
| 1716 | var as t = env.pa rse(input) ; | |||||
| 1717 | var en vironment = new env. Compiler() .compile(a st, option s); | |||||
| 1718 | return new env.J avaScriptC ompiler(). compile(en vironment, options); | |||||
| 1719 | } | |||||
| 1720 | ||||||
| 1721 | __export s__.precom pile = pre compile;fu nction com pile(input , options, env) { | |||||
| 1722 | if (in put == nul l || (type of input ! == 'string ' && input .construct or !== env .AST.Progr amNode)) { | |||||
| 1723 | thro w new Exce ption("You must pass a string or Handleb ars AST to Handlebar s.compile. You passe d " + inpu t); | |||||
| 1724 | } | |||||
| 1725 | ||||||
| 1726 | option s = option s || {}; | |||||
| 1727 | ||||||
| 1728 | if (!( 'data' in options)) { | |||||
| 1729 | opti ons.data = true; | |||||
| 1730 | } | |||||
| 1731 | ||||||
| 1732 | var co mpiled; | |||||
| 1733 | ||||||
| 1734 | functi on compile Input() { | |||||
| 1735 | var ast = env. parse(inpu t); | |||||
| 1736 | var environmen t = new en v.Compiler ().compile (ast, opti ons); | |||||
| 1737 | var templateSp ec = new e nv.JavaScr iptCompile r().compil e(environm ent, optio ns, undefi ned, true) ; | |||||
| 1738 | retu rn env.tem plate(temp lateSpec); | |||||
| 1739 | } | |||||
| 1740 | ||||||
| 1741 | // Tem plate is o nly compil ed on firs t use and cached aft er that po int. | |||||
| 1742 | return function( context, o ptions) { | |||||
| 1743 | if ( !compiled) { | |||||
| 1744 | co mpiled = c ompileInpu t(); | |||||
| 1745 | } | |||||
| 1746 | retu rn compile d.call(thi s, context , options) ; | |||||
| 1747 | }; | |||||
| 1748 | } | |||||
| 1749 | ||||||
| 1750 | __export s__.compil e = compil e; | |||||
| 1751 | return _ _exports__ ; | |||||
| 1752 | })(__modul e5__); | |||||
| 1753 | ||||||
| 1754 | // handleb ars/compil er/javascr ipt-compil er.js | |||||
| 1755 | var __modu le11__ = ( function(_ _dependenc y1__, __de pendency2_ _) { | |||||
| 1756 | "use str ict"; | |||||
| 1757 | var __ex ports__; | |||||
| 1758 | var COMP ILER_REVIS ION = __de pendency1_ _.COMPILER _REVISION; | |||||
| 1759 | var REVI SION_CHANG ES = __dep endency1__ .REVISION_ CHANGES; | |||||
| 1760 | var log = __depend ency1__.lo g; | |||||
| 1761 | var Exce ption = __ dependency 2__; | |||||
| 1762 | ||||||
| 1763 | function Literal(v alue) { | |||||
| 1764 | this.v alue = val ue; | |||||
| 1765 | } | |||||
| 1766 | ||||||
| 1767 | function JavaScrip tCompiler( ) {} | |||||
| 1768 | ||||||
| 1769 | JavaScri ptCompiler .prototype = { | |||||
| 1770 | // PUB LIC API: Y ou can ove rride thes e methods in a subcl ass to pro vide | |||||
| 1771 | // alt ernative c ompiled fo rms for na me lookup and buffer ing semant ics | |||||
| 1772 | nameLo okup: func tion(paren t, name /* , type*/) { | |||||
| 1773 | var wrap, | |||||
| 1774 | ret; | |||||
| 1775 | if ( parent.ind exOf('dept h') === 0) { | |||||
| 1776 | wr ap = true; | |||||
| 1777 | } | |||||
| 1778 | ||||||
| 1779 | if ( /^[0-9]+$/ .test(name )) { | |||||
| 1780 | re t = parent + "[" + n ame + "]"; | |||||
| 1781 | } el se if (Jav aScriptCom piler.isVa lidJavaScr iptVariabl eName(name )) { | |||||
| 1782 | re t = parent + "." + n ame; | |||||
| 1783 | } | |||||
| 1784 | else { | |||||
| 1785 | re t = parent + "['" + name + "'] "; | |||||
| 1786 | } | |||||
| 1787 | ||||||
| 1788 | if ( wrap) { | |||||
| 1789 | re turn '(' + parent + ' && ' + r et + ')'; | |||||
| 1790 | } el se { | |||||
| 1791 | re turn ret; | |||||
| 1792 | } | |||||
| 1793 | }, | |||||
| 1794 | ||||||
| 1795 | compil erInfo: fu nction() { | |||||
| 1796 | var revision = COMPILER_ REVISION, | |||||
| 1797 | versions = REVISION_ CHANGES[re vision]; | |||||
| 1798 | retu rn "this.c ompilerInf o = ["+rev ision+",'" +versions+ "'];\n"; | |||||
| 1799 | }, | |||||
| 1800 | ||||||
| 1801 | append ToBuffer: function(s tring) { | |||||
| 1802 | if ( this.envir onment.isS imple) { | |||||
| 1803 | re turn "retu rn " + str ing + ";"; | |||||
| 1804 | } el se { | |||||
| 1805 | re turn { | |||||
| 1806 | appendToBu ffer: true , | |||||
| 1807 | content: s tring, | |||||
| 1808 | toString: function() { return "buffer += " + strin g + ";"; } | |||||
| 1809 | }; | |||||
| 1810 | } | |||||
| 1811 | }, | |||||
| 1812 | ||||||
| 1813 | initia lizeBuffer : function () { | |||||
| 1814 | retu rn this.qu otedString (""); | |||||
| 1815 | }, | |||||
| 1816 | ||||||
| 1817 | namesp ace: "Hand lebars", | |||||
| 1818 | // END PUBLIC AP I | |||||
| 1819 | ||||||
| 1820 | compil e: functio n(environm ent, optio ns, contex t, asObjec t) { | |||||
| 1821 | this .environme nt = envir onment; | |||||
| 1822 | this .options = options | | {}; | |||||
| 1823 | ||||||
| 1824 | log( 'debug', t his.enviro nment.disa ssemble() + "\n\n"); | |||||
| 1825 | ||||||
| 1826 | this .name = th is.environ ment.name; | |||||
| 1827 | this .isChild = !!context ; | |||||
| 1828 | this .context = context | | { | |||||
| 1829 | pr ograms: [] , | |||||
| 1830 | en vironments : [], | |||||
| 1831 | al iases: { } | |||||
| 1832 | }; | |||||
| 1833 | ||||||
| 1834 | this .preamble( ); | |||||
| 1835 | ||||||
| 1836 | this .stackSlot = 0; | |||||
| 1837 | this .stackVars = []; | |||||
| 1838 | this .registers = { list: [] }; | |||||
| 1839 | this .hashes = []; | |||||
| 1840 | this .compileSt ack = []; | |||||
| 1841 | this .inlineSta ck = []; | |||||
| 1842 | ||||||
| 1843 | this .compileCh ildren(env ironment, options); | |||||
| 1844 | ||||||
| 1845 | var opcodes = environmen t.opcodes, opcode; | |||||
| 1846 | ||||||
| 1847 | this .i = 0; | |||||
| 1848 | ||||||
| 1849 | for( var l=opco des.length ; this.i<l ; this.i++ ) { | |||||
| 1850 | op code = opc odes[this. i]; | |||||
| 1851 | ||||||
| 1852 | if (opcode.op code === ' DECLARE') { | |||||
| 1853 | this[opcod e.name] = opcode.val ue; | |||||
| 1854 | } else { | |||||
| 1855 | this[opcod e.opcode]. apply(this , opcode.a rgs); | |||||
| 1856 | } | |||||
| 1857 | ||||||
| 1858 | // Reset the stripNext flag if i t was not set by thi s operatio n. | |||||
| 1859 | if (opcode.o pcode !== this.strip Next) { | |||||
| 1860 | this.strip Next = fal se; | |||||
| 1861 | } | |||||
| 1862 | } | |||||
| 1863 | ||||||
| 1864 | // F lush any t railing co ntent that might be pending. | |||||
| 1865 | this .pushSourc e(''); | |||||
| 1866 | ||||||
| 1867 | if ( this.stack Slot || th is.inlineS tack.lengt h || this. compileSta ck.length) { | |||||
| 1868 | th row new Ex ception('C ompile com pleted wit h content left on st ack'); | |||||
| 1869 | } | |||||
| 1870 | ||||||
| 1871 | retu rn this.cr eateFuncti onContext( asObject); | |||||
| 1872 | }, | |||||
| 1873 | ||||||
| 1874 | preamb le: functi on() { | |||||
| 1875 | var out = []; | |||||
| 1876 | ||||||
| 1877 | if ( !this.isCh ild) { | |||||
| 1878 | va r namespac e = this.n amespace; | |||||
| 1879 | ||||||
| 1880 | va r copies = "helpers = this.mer ge(helpers , " + name space + ". helpers);" ; | |||||
| 1881 | if (this.env ironment.u sePartial) { copies = copies + " partial s = this.m erge(parti als, " + n amespace + ".partial s);"; } | |||||
| 1882 | if (this.opt ions.data) { copies = copies + " data = data || {} ;"; } | |||||
| 1883 | ou t.push(cop ies); | |||||
| 1884 | } el se { | |||||
| 1885 | ou t.push('') ; | |||||
| 1886 | } | |||||
| 1887 | ||||||
| 1888 | if ( !this.envi ronment.is Simple) { | |||||
| 1889 | ou t.push(", buffer = " + this.in itializeBu ffer()); | |||||
| 1890 | } el se { | |||||
| 1891 | ou t.push("") ; | |||||
| 1892 | } | |||||
| 1893 | ||||||
| 1894 | // t rack the l ast contex t pushed i nto place to allow s kipping th e | |||||
| 1895 | // g etContext opcode whe n it would be a noop | |||||
| 1896 | this .lastConte xt = 0; | |||||
| 1897 | this .source = out; | |||||
| 1898 | }, | |||||
| 1899 | ||||||
| 1900 | create FunctionCo ntext: fun ction(asOb ject) { | |||||
| 1901 | var locals = t his.stackV ars.concat (this.regi sters.list ); | |||||
| 1902 | ||||||
| 1903 | if(l ocals.leng th > 0) { | |||||
| 1904 | th is.source[ 1] = this. source[1] + ", " + l ocals.join (", "); | |||||
| 1905 | } | |||||
| 1906 | ||||||
| 1907 | // G enerate mi nimizer al ias mappin gs | |||||
| 1908 | if ( !this.isCh ild) { | |||||
| 1909 | fo r (var ali as in this .context.a liases) { | |||||
| 1910 | if (this.c ontext.ali ases.hasOw nProperty( alias)) { | |||||
| 1911 | this.sou rce[1] = t his.source [1] + ', ' + alias + '=' + thi s.context. aliases[al ias]; | |||||
| 1912 | } | |||||
| 1913 | } | |||||
| 1914 | } | |||||
| 1915 | ||||||
| 1916 | if ( this.sourc e[1]) { | |||||
| 1917 | th is.source[ 1] = "var " + this.s ource[1].s ubstring(2 ) + ";"; | |||||
| 1918 | } | |||||
| 1919 | ||||||
| 1920 | // M erge child ren | |||||
| 1921 | if ( !this.isCh ild) { | |||||
| 1922 | th is.source[ 1] += '\n' + this.co ntext.prog rams.join( '\n') + '\ n'; | |||||
| 1923 | } | |||||
| 1924 | ||||||
| 1925 | if ( !this.envi ronment.is Simple) { | |||||
| 1926 | th is.pushSou rce("retur n buffer;" ); | |||||
| 1927 | } | |||||
| 1928 | ||||||
| 1929 | var params = t his.isChil d ? ["dept h0", "data "] : ["Han dlebars", "depth0", "helpers", "partials ", "data"] ; | |||||
| 1930 | ||||||
| 1931 | for( var i=0, l =this.envi ronment.de pths.list. length; i< l; i++) { | |||||
| 1932 | pa rams.push( "depth" + this.envir onment.dep ths.list[i ]); | |||||
| 1933 | } | |||||
| 1934 | ||||||
| 1935 | // P erform a s econd pass over the output to merge cont ent when p ossible | |||||
| 1936 | var source = t his.mergeS ource(); | |||||
| 1937 | ||||||
| 1938 | if ( !this.isCh ild) { | |||||
| 1939 | so urce = thi s.compiler Info()+sou rce; | |||||
| 1940 | } | |||||
| 1941 | ||||||
| 1942 | if ( asObject) { | |||||
| 1943 | pa rams.push( source); | |||||
| 1944 | ||||||
| 1945 | re turn Funct ion.apply( this, para ms); | |||||
| 1946 | } el se { | |||||
| 1947 | va r function Source = ' function ' + (this.n ame || '') + '(' + p arams.join (',') + ') {\n ' + source + ' }'; | |||||
| 1948 | lo g('debug', functionS ource + "\ n\n"); | |||||
| 1949 | re turn funct ionSource; | |||||
| 1950 | } | |||||
| 1951 | }, | |||||
| 1952 | mergeS ource: fun ction() { | |||||
| 1953 | // W ARN: We ar e not hand ling the c ase where buffer is still popu lated as t he source should | |||||
| 1954 | // n ot have bu ffer appen d operatio ns as thei r final ac tion. | |||||
| 1955 | var source = ' ', | |||||
| 1956 | buffer; | |||||
| 1957 | for (var i = 0 , len = th is.source. length; i < len; i++ ) { | |||||
| 1958 | va r line = t his.source [i]; | |||||
| 1959 | if (line.app endToBuffe r) { | |||||
| 1960 | if (buffer ) { | |||||
| 1961 | buffer = buffer + '\n + ' + line.co ntent; | |||||
| 1962 | } else { | |||||
| 1963 | buffer = line.cont ent; | |||||
| 1964 | } | |||||
| 1965 | } else { | |||||
| 1966 | if (buffer ) { | |||||
| 1967 | source + = 'buffer += ' + buf fer + ';\n '; | |||||
| 1968 | buffer = undefined ; | |||||
| 1969 | } | |||||
| 1970 | source += line + '\n '; | |||||
| 1971 | } | |||||
| 1972 | } | |||||
| 1973 | retu rn source; | |||||
| 1974 | }, | |||||
| 1975 | ||||||
| 1976 | // [bl ockValue] | |||||
| 1977 | // | |||||
| 1978 | // On stack, bef ore: hash, inverse, program, v alue | |||||
| 1979 | // On stack, aft er: return value of blockHelpe rMissing | |||||
| 1980 | // | |||||
| 1981 | // The purpose o f this opc ode is to take a blo ck of the form | |||||
| 1982 | // `{{ #foo}}...{ {/foo}}`, resolve th e value of `foo`, an d | |||||
| 1983 | // rep lace it on the stack with the result of properly | |||||
| 1984 | // inv oking bloc kHelperMis sing. | |||||
| 1985 | blockV alue: func tion() { | |||||
| 1986 | this .context.a liases.blo ckHelperMi ssing = 'h elpers.blo ckHelperMi ssing'; | |||||
| 1987 | ||||||
| 1988 | var params = [ "depth0"]; | |||||
| 1989 | this .setupPara ms(0, para ms); | |||||
| 1990 | ||||||
| 1991 | this .replaceSt ack(functi on(current ) { | |||||
| 1992 | pa rams.splic e(1, 0, cu rrent); | |||||
| 1993 | re turn "bloc kHelperMis sing.call( " + params .join(", " ) + ")"; | |||||
| 1994 | }); | |||||
| 1995 | }, | |||||
| 1996 | ||||||
| 1997 | // [am biguousBlo ckValue] | |||||
| 1998 | // | |||||
| 1999 | // On stack, bef ore: hash, inverse, program, v alue | |||||
| 2000 | // Com piler valu e, before: lastHelpe r=value of last foun d helper, if any | |||||
| 2001 | // On stack, aft er, if no lastHelper : same as [blockValu e] | |||||
| 2002 | // On stack, aft er, if las tHelper: v alue | |||||
| 2003 | ambigu ousBlockVa lue: funct ion() { | |||||
| 2004 | this .context.a liases.blo ckHelperMi ssing = 'h elpers.blo ckHelperMi ssing'; | |||||
| 2005 | ||||||
| 2006 | var params = [ "depth0"]; | |||||
| 2007 | this .setupPara ms(0, para ms); | |||||
| 2008 | ||||||
| 2009 | var current = this.topSt ack(); | |||||
| 2010 | para ms.splice( 1, 0, curr ent); | |||||
| 2011 | ||||||
| 2012 | this .pushSourc e("if (!" + this.las tHelper + ") { " + c urrent + " = blockHe lperMissin g.call(" + params.jo in(", ") + "); }"); | |||||
| 2013 | }, | |||||
| 2014 | ||||||
| 2015 | // [ap pendConten t] | |||||
| 2016 | // | |||||
| 2017 | // On stack, bef ore: ... | |||||
| 2018 | // On stack, aft er: ... | |||||
| 2019 | // | |||||
| 2020 | // App ends the s tring valu e of `cont ent` to th e current buffer | |||||
| 2021 | append Content: f unction(co ntent) { | |||||
| 2022 | if ( this.pendi ngContent) { | |||||
| 2023 | co ntent = th is.pending Content + content; | |||||
| 2024 | } | |||||
| 2025 | if ( this.strip Next) { | |||||
| 2026 | co ntent = co ntent.repl ace(/^\s+/ , ''); | |||||
| 2027 | } | |||||
| 2028 | ||||||
| 2029 | this .pendingCo ntent = co ntent; | |||||
| 2030 | }, | |||||
| 2031 | ||||||
| 2032 | // [st rip] | |||||
| 2033 | // | |||||
| 2034 | // On stack, bef ore: ... | |||||
| 2035 | // On stack, aft er: ... | |||||
| 2036 | // | |||||
| 2037 | // Rem oves any t railing wh itespace f rom the pr ior conten t node and flags | |||||
| 2038 | // the next oper ation for stripping if it is a content n ode. | |||||
| 2039 | strip: function( ) { | |||||
| 2040 | if ( this.pendi ngContent) { | |||||
| 2041 | th is.pending Content = this.pendi ngContent. replace(/\ s+$/, ''); | |||||
| 2042 | } | |||||
| 2043 | this .stripNext = 'strip' ; | |||||
| 2044 | }, | |||||
| 2045 | ||||||
| 2046 | // [ap pend] | |||||
| 2047 | // | |||||
| 2048 | // On stack, bef ore: value , ... | |||||
| 2049 | // On stack, aft er: ... | |||||
| 2050 | // | |||||
| 2051 | // Coe rces `valu e` to a St ring and a ppends it to the cur rent buffe r. | |||||
| 2052 | // | |||||
| 2053 | // If `value` is truthy, o r 0, it is coerced i nto a stri ng and app ended | |||||
| 2054 | // Oth erwise, th e empty st ring is ap pended | |||||
| 2055 | append : function () { | |||||
| 2056 | // F orce anyth ing that i s inlined onto the s tack so we don't hav e duplicat ion | |||||
| 2057 | // w hen we exa mine local | |||||
| 2058 | this .flushInli ne(); | |||||
| 2059 | var local = th is.popStac k(); | |||||
| 2060 | this .pushSourc e("if(" + local + " || " + loc al + " === 0) { " + this.appen dToBuffer( local) + " }"); | |||||
| 2061 | if ( this.envir onment.isS imple) { | |||||
| 2062 | th is.pushSou rce("else { " + this .appendToB uffer("''" ) + " }"); | |||||
| 2063 | } | |||||
| 2064 | }, | |||||
| 2065 | ||||||
| 2066 | // [ap pendEscape d] | |||||
| 2067 | // | |||||
| 2068 | // On stack, bef ore: value , ... | |||||
| 2069 | // On stack, aft er: ... | |||||
| 2070 | // | |||||
| 2071 | // Esc ape `value ` and appe nd it to t he buffer | |||||
| 2072 | append Escaped: f unction() { | |||||
| 2073 | this .context.a liases.esc apeExpress ion = 'thi s.escapeEx pression'; | |||||
| 2074 | ||||||
| 2075 | this .pushSourc e(this.app endToBuffe r("escapeE xpression( " + this.p opStack() + ")")); | |||||
| 2076 | }, | |||||
| 2077 | ||||||
| 2078 | // [ge tContext] | |||||
| 2079 | // | |||||
| 2080 | // On stack, bef ore: ... | |||||
| 2081 | // On stack, aft er: ... | |||||
| 2082 | // Com piler valu e, after: lastContex t=depth | |||||
| 2083 | // | |||||
| 2084 | // Set the value of the `l astContext ` compiler value to the depth | |||||
| 2085 | getCon text: func tion(depth ) { | |||||
| 2086 | if(t his.lastCo ntext !== depth) { | |||||
| 2087 | th is.lastCon text = dep th; | |||||
| 2088 | } | |||||
| 2089 | }, | |||||
| 2090 | ||||||
| 2091 | // [lo okupOnCont ext] | |||||
| 2092 | // | |||||
| 2093 | // On stack, bef ore: ... | |||||
| 2094 | // On stack, aft er: curren tContext[n ame], ... | |||||
| 2095 | // | |||||
| 2096 | // Loo ks up the value of ` name` on t he current context a nd pushes | |||||
| 2097 | // it onto the s tack. | |||||
| 2098 | lookup OnContext: function( name) { | |||||
| 2099 | this .push(this .nameLooku p('depth' + this.las tContext, name, 'con text')); | |||||
| 2100 | }, | |||||
| 2101 | ||||||
| 2102 | // [pu shContext] | |||||
| 2103 | // | |||||
| 2104 | // On stack, bef ore: ... | |||||
| 2105 | // On stack, aft er: curren tContext, ... | |||||
| 2106 | // | |||||
| 2107 | // Pus hes the va lue of the current c ontext ont o the stac k. | |||||
| 2108 | pushCo ntext: fun ction() { | |||||
| 2109 | this .pushStack Literal('d epth' + th is.lastCon text); | |||||
| 2110 | }, | |||||
| 2111 | ||||||
| 2112 | // [re solvePossi bleLambda] | |||||
| 2113 | // | |||||
| 2114 | // On stack, bef ore: value , ... | |||||
| 2115 | // On stack, aft er: resolv ed value, ... | |||||
| 2116 | // | |||||
| 2117 | // If the `value ` is a lam bda, repla ce it on t he stack b y | |||||
| 2118 | // the return va lue of the lambda | |||||
| 2119 | resolv ePossibleL ambda: fun ction() { | |||||
| 2120 | this .context.a liases.fun ctionType = '"functi on"'; | |||||
| 2121 | ||||||
| 2122 | this .replaceSt ack(functi on(current ) { | |||||
| 2123 | re turn "type of " + cur rent + " = == functio nType ? " + current + ".apply( depth0) : " + curren t; | |||||
| 2124 | }); | |||||
| 2125 | }, | |||||
| 2126 | ||||||
| 2127 | // [lo okup] | |||||
| 2128 | // | |||||
| 2129 | // On stack, bef ore: value , ... | |||||
| 2130 | // On stack, aft er: value[ name], ... | |||||
| 2131 | // | |||||
| 2132 | // Rep lace the v alue on th e stack wi th the res ult of loo king | |||||
| 2133 | // up `name` on `value` | |||||
| 2134 | lookup : function (name) { | |||||
| 2135 | this .replaceSt ack(functi on(current ) { | |||||
| 2136 | re turn curre nt + " == null || " + current + " === fa lse ? " + current + " : " + th is.nameLoo kup(curren t, name, ' context'); | |||||
| 2137 | }); | |||||
| 2138 | }, | |||||
| 2139 | ||||||
| 2140 | // [lo okupData] | |||||
| 2141 | // | |||||
| 2142 | // On stack, bef ore: ... | |||||
| 2143 | // On stack, aft er: data, ... | |||||
| 2144 | // | |||||
| 2145 | // Pus h the data lookup op erator | |||||
| 2146 | lookup Data: func tion() { | |||||
| 2147 | this .pushStack Literal('d ata'); | |||||
| 2148 | }, | |||||
| 2149 | ||||||
| 2150 | // [pu shStringPa ram] | |||||
| 2151 | // | |||||
| 2152 | // On stack, bef ore: ... | |||||
| 2153 | // On stack, aft er: string , currentC ontext, .. . | |||||
| 2154 | // | |||||
| 2155 | // Thi s opcode i s designed for use i n string m ode, which | |||||
| 2156 | // pro vides the string val ue of a pa rameter al ong with i ts | |||||
| 2157 | // dep th rather than resol ving it im mediately. | |||||
| 2158 | pushSt ringParam: function( string, ty pe) { | |||||
| 2159 | this .pushStack Literal('d epth' + th is.lastCon text); | |||||
| 2160 | ||||||
| 2161 | this .pushStrin g(type); | |||||
| 2162 | ||||||
| 2163 | // I f it's a s ubexpressi on, the st ring resul t | |||||
| 2164 | // w ill be pus hed after this opcod e. | |||||
| 2165 | if ( type !== ' sexpr') { | |||||
| 2166 | if (typeof s tring === 'string') { | |||||
| 2167 | this.pushS tring(stri ng); | |||||
| 2168 | } else { | |||||
| 2169 | this.pushS tackLitera l(string); | |||||
| 2170 | } | |||||
| 2171 | } | |||||
| 2172 | }, | |||||
| 2173 | ||||||
| 2174 | emptyH ash: funct ion() { | |||||
| 2175 | this .pushStack Literal('{ }'); | |||||
| 2176 | ||||||
| 2177 | if ( this.optio ns.stringP arams) { | |||||
| 2178 | th is.push('{ }'); // ha shContexts | |||||
| 2179 | th is.push('{ }'); // ha shTypes | |||||
| 2180 | } | |||||
| 2181 | }, | |||||
| 2182 | pushHa sh: functi on() { | |||||
| 2183 | if ( this.hash) { | |||||
| 2184 | th is.hashes. push(this. hash); | |||||
| 2185 | } | |||||
| 2186 | this .hash = {v alues: [], types: [] , contexts : []}; | |||||
| 2187 | }, | |||||
| 2188 | popHas h: functio n() { | |||||
| 2189 | var hash = thi s.hash; | |||||
| 2190 | this .hash = th is.hashes. pop(); | |||||
| 2191 | ||||||
| 2192 | if ( this.optio ns.stringP arams) { | |||||
| 2193 | th is.push('{ ' + hash.c ontexts.jo in(',') + '}'); | |||||
| 2194 | th is.push('{ ' + hash.t ypes.join( ',') + '}' ); | |||||
| 2195 | } | |||||
| 2196 | ||||||
| 2197 | this .push('{\n ' + ha sh.values. join(',\n ') + '\ n }'); | |||||
| 2198 | }, | |||||
| 2199 | ||||||
| 2200 | // [pu shString] | |||||
| 2201 | // | |||||
| 2202 | // On stack, bef ore: ... | |||||
| 2203 | // On stack, aft er: quoted String(str ing), ... | |||||
| 2204 | // | |||||
| 2205 | // Pus h a quoted version o f `string` onto the stack | |||||
| 2206 | pushSt ring: func tion(strin g) { | |||||
| 2207 | this .pushStack Literal(th is.quotedS tring(stri ng)); | |||||
| 2208 | }, | |||||
| 2209 | ||||||
| 2210 | // [pu sh] | |||||
| 2211 | // | |||||
| 2212 | // On stack, bef ore: ... | |||||
| 2213 | // On stack, aft er: expr, ... | |||||
| 2214 | // | |||||
| 2215 | // Pus h an expre ssion onto the stack | |||||
| 2216 | push: function(e xpr) { | |||||
| 2217 | this .inlineSta ck.push(ex pr); | |||||
| 2218 | retu rn expr; | |||||
| 2219 | }, | |||||
| 2220 | ||||||
| 2221 | // [pu shLiteral] | |||||
| 2222 | // | |||||
| 2223 | // On stack, bef ore: ... | |||||
| 2224 | // On stack, aft er: value, ... | |||||
| 2225 | // | |||||
| 2226 | // Pus hes a valu e onto the stack. Th is operati on prevent s | |||||
| 2227 | // the compiler from creat ing a temp orary vari able to ho ld | |||||
| 2228 | // it. | |||||
| 2229 | pushLi teral: fun ction(valu e) { | |||||
| 2230 | this .pushStack Literal(va lue); | |||||
| 2231 | }, | |||||
| 2232 | ||||||
| 2233 | // [pu shProgram] | |||||
| 2234 | // | |||||
| 2235 | // On stack, bef ore: ... | |||||
| 2236 | // On stack, aft er: progra m(guid), . .. | |||||
| 2237 | // | |||||
| 2238 | // Pus h a progra m expressi on onto th e stack. T his takes | |||||
| 2239 | // a c ompile-tim e guid and converts it into a runtime-ac cessible | |||||
| 2240 | // exp ression. | |||||
| 2241 | pushPr ogram: fun ction(guid ) { | |||||
| 2242 | if ( guid != nu ll) { | |||||
| 2243 | th is.pushSta ckLiteral( this.progr amExpressi on(guid)); | |||||
| 2244 | } el se { | |||||
| 2245 | th is.pushSta ckLiteral( null); | |||||
| 2246 | } | |||||
| 2247 | }, | |||||
| 2248 | ||||||
| 2249 | // [in vokeHelper ] | |||||
| 2250 | // | |||||
| 2251 | // On stack, bef ore: hash, inverse, program, p arams..., ... | |||||
| 2252 | // On stack, aft er: result of helper invocatio n | |||||
| 2253 | // | |||||
| 2254 | // Pop s off the helper's p arameters, invokes t he helper, | |||||
| 2255 | // and pushes th e helper's return va lue onto t he stack. | |||||
| 2256 | // | |||||
| 2257 | // If the helper is not fo und, `help erMissing` is called . | |||||
| 2258 | invoke Helper: fu nction(par amSize, na me, isRoot ) { | |||||
| 2259 | this .context.a liases.hel perMissing = 'helper s.helperMi ssing'; | |||||
| 2260 | this .useRegist er('helper '); | |||||
| 2261 | ||||||
| 2262 | var helper = t his.lastHe lper = thi s.setupHel per(paramS ize, name, true); | |||||
| 2263 | var nonHelper = this.nam eLookup('d epth' + th is.lastCon text, name , 'context '); | |||||
| 2264 | ||||||
| 2265 | var lookup = ' helper = ' + helper. name + ' | | ' + nonH elper; | |||||
| 2266 | if ( helper.par amsInit) { | |||||
| 2267 | lo okup += ', ' + helper .paramsIni t; | |||||
| 2268 | } | |||||
| 2269 | ||||||
| 2270 | this .push( | |||||
| 2271 | '( ' | |||||
| 2272 | + lookup | |||||
| 2273 | + ',helper ' | |||||
| 2274 | + '? hel per.call(' + helper. callParams + ') ' | |||||
| 2275 | + ': hel perMissing .call(' + helper.hel perMissing Params + ' ))'); | |||||
| 2276 | ||||||
| 2277 | // A lways flus h subexpre ssions. Th is is both to preven t the comp ounding si ze issue t hat | |||||
| 2278 | // o ccurs when the code has to be duplicated for inlin ing and al so to prev ent errors | |||||
| 2279 | // d ue to the incorrect options ob ject being passed du e to the s hared regi ster. | |||||
| 2280 | if ( !isRoot) { | |||||
| 2281 | th is.flushIn line(); | |||||
| 2282 | } | |||||
| 2283 | }, | |||||
| 2284 | ||||||
| 2285 | // [in vokeKnownH elper] | |||||
| 2286 | // | |||||
| 2287 | // On stack, bef ore: hash, inverse, program, p arams..., ... | |||||
| 2288 | // On stack, aft er: result of helper invocatio n | |||||
| 2289 | // | |||||
| 2290 | // Thi s operatio n is used when the h elper is k nown to ex ist, | |||||
| 2291 | // so a `helperM issing` fa llback is not requir ed. | |||||
| 2292 | invoke KnownHelpe r: functio n(paramSiz e, name) { | |||||
| 2293 | var helper = t his.setupH elper(para mSize, nam e); | |||||
| 2294 | this .push(help er.name + ".call(" + helper.ca llParams + ")"); | |||||
| 2295 | }, | |||||
| 2296 | ||||||
| 2297 | // [in vokeAmbigu ous] | |||||
| 2298 | // | |||||
| 2299 | // On stack, bef ore: hash, inverse, program, p arams..., ... | |||||
| 2300 | // On stack, aft er: result of disamb iguation | |||||
| 2301 | // | |||||
| 2302 | // Thi s operatio n is used when an ex pression l ike `{{foo }}` | |||||
| 2303 | // is provided, but we don 't know at compile-t ime whethe r it | |||||
| 2304 | // is a helper o r a path. | |||||
| 2305 | // | |||||
| 2306 | // Thi s operatio n emits mo re code th an the oth er options , | |||||
| 2307 | // and can be av oided by p assing the `knownHel pers` and | |||||
| 2308 | // `kn ownHelpers Only` flag s at compi le-time. | |||||
| 2309 | invoke Ambiguous: function( name, help erCall) { | |||||
| 2310 | this .context.a liases.fun ctionType = '"functi on"'; | |||||
| 2311 | this .useRegist er('helper '); | |||||
| 2312 | ||||||
| 2313 | this .emptyHash (); | |||||
| 2314 | var helper = t his.setupH elper(0, n ame, helpe rCall); | |||||
| 2315 | ||||||
| 2316 | var helperName = this.la stHelper = this.name Lookup('he lpers', na me, 'helpe r'); | |||||
| 2317 | ||||||
| 2318 | var nonHelper = this.nam eLookup('d epth' + th is.lastCon text, name , 'context '); | |||||
| 2319 | var nextStack = this.nex tStack(); | |||||
| 2320 | ||||||
| 2321 | if ( helper.par amsInit) { | |||||
| 2322 | th is.pushSou rce(helper .paramsIni t); | |||||
| 2323 | } | |||||
| 2324 | this .pushSourc e('if (hel per = ' + helperName + ') { ' + nextStac k + ' = he lper.call( ' + helper .callParam s + '); }' ); | |||||
| 2325 | this .pushSourc e('else { helper = ' + nonHelp er + '; ' + nextStac k + ' = ty peof helpe r === func tionType ? helper.ca ll(' + hel per.callPa rams + ') : helper; }'); | |||||
| 2326 | }, | |||||
| 2327 | ||||||
| 2328 | // [in vokePartia l] | |||||
| 2329 | // | |||||
| 2330 | // On stack, bef ore: conte xt, ... | |||||
| 2331 | // On stack afte r: result of partial invocatio n | |||||
| 2332 | // | |||||
| 2333 | // Thi s operatio n pops off a context , invokes a partial with that context, | |||||
| 2334 | // and pushes th e result o f the invo cation bac k. | |||||
| 2335 | invoke Partial: f unction(na me) { | |||||
| 2336 | var params = [ this.nameL ookup('par tials', na me, 'parti al'), "'" + name + " '", this.p opStack(), "helpers" , "partial s"]; | |||||
| 2337 | ||||||
| 2338 | if ( this.optio ns.data) { | |||||
| 2339 | pa rams.push( "data"); | |||||
| 2340 | } | |||||
| 2341 | ||||||
| 2342 | this .context.a liases.sel f = "this" ; | |||||
| 2343 | this .push("sel f.invokePa rtial(" + params.joi n(", ") + ")"); | |||||
| 2344 | }, | |||||
| 2345 | ||||||
| 2346 | // [as signToHash ] | |||||
| 2347 | // | |||||
| 2348 | // On stack, bef ore: value , hash, .. . | |||||
| 2349 | // On stack, aft er: hash, ... | |||||
| 2350 | // | |||||
| 2351 | // Pop s a value and hash o ff the sta ck, assign s `hash[ke y] = value ` | |||||
| 2352 | // and pushes th e hash bac k onto the stack. | |||||
| 2353 | assign ToHash: fu nction(key ) { | |||||
| 2354 | var value = th is.popStac k(), | |||||
| 2355 | context, | |||||
| 2356 | type; | |||||
| 2357 | ||||||
| 2358 | if ( this.optio ns.stringP arams) { | |||||
| 2359 | ty pe = this. popStack() ; | |||||
| 2360 | co ntext = th is.popStac k(); | |||||
| 2361 | } | |||||
| 2362 | ||||||
| 2363 | var hash = thi s.hash; | |||||
| 2364 | if ( context) { | |||||
| 2365 | ha sh.context s.push("'" + key + " ': " + con text); | |||||
| 2366 | } | |||||
| 2367 | if ( type) { | |||||
| 2368 | ha sh.types.p ush("'" + key + "': " + type); | |||||
| 2369 | } | |||||
| 2370 | hash .values.pu sh("'" + k ey + "': ( " + value + ")"); | |||||
| 2371 | }, | |||||
| 2372 | ||||||
| 2373 | // HEL PERS | |||||
| 2374 | ||||||
| 2375 | compil er: JavaSc riptCompil er, | |||||
| 2376 | ||||||
| 2377 | compil eChildren: function( environmen t, options ) { | |||||
| 2378 | var children = environme nt.childre n, child, compiler; | |||||
| 2379 | ||||||
| 2380 | for( var i=0, l =children. length; i< l; i++) { | |||||
| 2381 | ch ild = chil dren[i]; | |||||
| 2382 | co mpiler = n ew this.co mpiler(); | |||||
| 2383 | ||||||
| 2384 | va r index = this.match ExistingPr ogram(chil d); | |||||
| 2385 | ||||||
| 2386 | if (index == null) { | |||||
| 2387 | this.conte xt.program s.push('') ; // P laceholder to preven t name con flicts for nested ch ildren | |||||
| 2388 | index = th is.context .programs. length; | |||||
| 2389 | child.inde x = index; | |||||
| 2390 | child.name = 'progra m' + index ; | |||||
| 2391 | this.conte xt.program s[index] = compiler. compile(ch ild, optio ns, this.c ontext); | |||||
| 2392 | this.conte xt.environ ments[inde x] = child ; | |||||
| 2393 | } else { | |||||
| 2394 | child.inde x = index; | |||||
| 2395 | child.name = 'progra m' + index ; | |||||
| 2396 | } | |||||
| 2397 | } | |||||
| 2398 | }, | |||||
| 2399 | matchE xistingPro gram: func tion(child ) { | |||||
| 2400 | for (var i = 0 , len = th is.context .environme nts.length ; i < len; i++) { | |||||
| 2401 | va r environm ent = this .context.e nvironment s[i]; | |||||
| 2402 | if (environm ent && env ironment.e quals(chil d)) { | |||||
| 2403 | return i; | |||||
| 2404 | } | |||||
| 2405 | } | |||||
| 2406 | }, | |||||
| 2407 | ||||||
| 2408 | progra mExpressio n: functio n(guid) { | |||||
| 2409 | this .context.a liases.sel f = "this" ; | |||||
| 2410 | ||||||
| 2411 | if(g uid == nul l) { | |||||
| 2412 | re turn "self .noop"; | |||||
| 2413 | } | |||||
| 2414 | ||||||
| 2415 | var child = th is.environ ment.child ren[guid], | |||||
| 2416 | depths = c hild.depth s.list, de pth; | |||||
| 2417 | ||||||
| 2418 | var programPar ams = [chi ld.index, child.name , "data"]; | |||||
| 2419 | ||||||
| 2420 | for( var i=0, l = depths. length; i< l; i++) { | |||||
| 2421 | de pth = dept hs[i]; | |||||
| 2422 | ||||||
| 2423 | if (depth === 1) { prog ramParams. push("dept h0"); } | |||||
| 2424 | el se { progr amParams.p ush("depth " + (depth - 1)); } | |||||
| 2425 | } | |||||
| 2426 | ||||||
| 2427 | retu rn (depths .length == = 0 ? "sel f.program( " : "self. programWit hDepth(") + programP arams.join (", ") + " )"; | |||||
| 2428 | }, | |||||
| 2429 | ||||||
| 2430 | regist er: functi on(name, v al) { | |||||
| 2431 | this .useRegist er(name); | |||||
| 2432 | this .pushSourc e(name + " = " + val + ";"); | |||||
| 2433 | }, | |||||
| 2434 | ||||||
| 2435 | useReg ister: fun ction(name ) { | |||||
| 2436 | if(! this.regis ters[name] ) { | |||||
| 2437 | th is.registe rs[name] = true; | |||||
| 2438 | th is.registe rs.list.pu sh(name); | |||||
| 2439 | } | |||||
| 2440 | }, | |||||
| 2441 | ||||||
| 2442 | pushSt ackLiteral : function (item) { | |||||
| 2443 | retu rn this.pu sh(new Lit eral(item) ); | |||||
| 2444 | }, | |||||
| 2445 | ||||||
| 2446 | pushSo urce: func tion(sourc e) { | |||||
| 2447 | if ( this.pendi ngContent) { | |||||
| 2448 | th is.source. push(this. appendToBu ffer(this. quotedStri ng(this.pe ndingConte nt))); | |||||
| 2449 | th is.pending Content = undefined; | |||||
| 2450 | } | |||||
| 2451 | ||||||
| 2452 | if ( source) { | |||||
| 2453 | th is.source. push(sourc e); | |||||
| 2454 | } | |||||
| 2455 | }, | |||||
| 2456 | ||||||
| 2457 | pushSt ack: funct ion(item) { | |||||
| 2458 | this .flushInli ne(); | |||||
| 2459 | ||||||
| 2460 | var stack = th is.incrSta ck(); | |||||
| 2461 | if ( item) { | |||||
| 2462 | th is.pushSou rce(stack + " = " + item + ";" ); | |||||
| 2463 | } | |||||
| 2464 | this .compileSt ack.push(s tack); | |||||
| 2465 | retu rn stack; | |||||
| 2466 | }, | |||||
| 2467 | ||||||
| 2468 | replac eStack: fu nction(cal lback) { | |||||
| 2469 | var prefix = ' ', | |||||
| 2470 | inline = t his.isInli ne(), | |||||
| 2471 | stack, | |||||
| 2472 | createdSta ck, | |||||
| 2473 | usedLitera l; | |||||
| 2474 | ||||||
| 2475 | // I f we are c urrently i nline then we want t o merge th e inline s tatement i nto the | |||||
| 2476 | // r eplacement statement via ',' | |||||
| 2477 | if ( inline) { | |||||
| 2478 | va r top = th is.popStac k(true); | |||||
| 2479 | ||||||
| 2480 | if (top inst anceof Lit eral) { | |||||
| 2481 | // Literal s do not n eed to be inlined | |||||
| 2482 | stack = to p.value; | |||||
| 2483 | usedLitera l = true; | |||||
| 2484 | } else { | |||||
| 2485 | // Get or create the current s tack name for use by the inlin e | |||||
| 2486 | createdSta ck = !this .stackSlot ; | |||||
| 2487 | var name = !createdS tack ? thi s.topStack Name() : t his.incrSt ack(); | |||||
| 2488 | ||||||
| 2489 | prefix = ' (' + this. push(name) + ' = ' + top + '), '; | |||||
| 2490 | stack = th is.topStac k(); | |||||
| 2491 | } | |||||
| 2492 | } el se { | |||||
| 2493 | st ack = this .topStack( ); | |||||
| 2494 | } | |||||
| 2495 | ||||||
| 2496 | var item = cal lback.call (this, sta ck); | |||||
| 2497 | ||||||
| 2498 | if ( inline) { | |||||
| 2499 | if (!usedLit eral) { | |||||
| 2500 | this.popSt ack(); | |||||
| 2501 | } | |||||
| 2502 | if (createdS tack) { | |||||
| 2503 | this.stack Slot--; | |||||
| 2504 | } | |||||
| 2505 | th is.push('( ' + prefix + item + ')'); | |||||
| 2506 | } el se { | |||||
| 2507 | // Prevent m odificatio n of the c ontext dep th variabl e. Through replaceSt ack | |||||
| 2508 | if (!/^stack /.test(sta ck)) { | |||||
| 2509 | stack = th is.nextSta ck(); | |||||
| 2510 | } | |||||
| 2511 | ||||||
| 2512 | th is.pushSou rce(stack + " = (" + prefix + item + "); "); | |||||
| 2513 | } | |||||
| 2514 | retu rn stack; | |||||
| 2515 | }, | |||||
| 2516 | ||||||
| 2517 | nextSt ack: funct ion() { | |||||
| 2518 | retu rn this.pu shStack(); | |||||
| 2519 | }, | |||||
| 2520 | ||||||
| 2521 | incrSt ack: funct ion() { | |||||
| 2522 | this .stackSlot ++; | |||||
| 2523 | if(t his.stackS lot > this .stackVars .length) { this.stac kVars.push ("stack" + this.stac kSlot); } | |||||
| 2524 | retu rn this.to pStackName (); | |||||
| 2525 | }, | |||||
| 2526 | topSta ckName: fu nction() { | |||||
| 2527 | retu rn "stack" + this.st ackSlot; | |||||
| 2528 | }, | |||||
| 2529 | flushI nline: fun ction() { | |||||
| 2530 | var inlineStac k = this.i nlineStack ; | |||||
| 2531 | if ( inlineStac k.length) { | |||||
| 2532 | th is.inlineS tack = []; | |||||
| 2533 | fo r (var i = 0, len = inlineStac k.length; i < len; i ++) { | |||||
| 2534 | var entry = inlineSt ack[i]; | |||||
| 2535 | if (entry instanceof Literal) { | |||||
| 2536 | this.com pileStack. push(entry ); | |||||
| 2537 | } else { | |||||
| 2538 | this.pus hStack(ent ry); | |||||
| 2539 | } | |||||
| 2540 | } | |||||
| 2541 | } | |||||
| 2542 | }, | |||||
| 2543 | isInli ne: functi on() { | |||||
| 2544 | retu rn this.in lineStack. length; | |||||
| 2545 | }, | |||||
| 2546 | ||||||
| 2547 | popSta ck: functi on(wrapped ) { | |||||
| 2548 | var inline = t his.isInli ne(), | |||||
| 2549 | item = (in line ? thi s.inlineSt ack : this .compileSt ack).pop() ; | |||||
| 2550 | ||||||
| 2551 | if ( !wrapped & & (item in stanceof L iteral)) { | |||||
| 2552 | re turn item. value; | |||||
| 2553 | } el se { | |||||
| 2554 | if (!inline) { | |||||
| 2555 | if (!this. stackSlot) { | |||||
| 2556 | throw ne w Exceptio n('Invalid stack pop '); | |||||
| 2557 | } | |||||
| 2558 | this.stack Slot--; | |||||
| 2559 | } | |||||
| 2560 | re turn item; | |||||
| 2561 | } | |||||
| 2562 | }, | |||||
| 2563 | ||||||
| 2564 | topSta ck: functi on(wrapped ) { | |||||
| 2565 | var stack = (t his.isInli ne() ? thi s.inlineSt ack : this .compileSt ack), | |||||
| 2566 | item = sta ck[stack.l ength - 1] ; | |||||
| 2567 | ||||||
| 2568 | if ( !wrapped & & (item in stanceof L iteral)) { | |||||
| 2569 | re turn item. value; | |||||
| 2570 | } el se { | |||||
| 2571 | re turn item; | |||||
| 2572 | } | |||||
| 2573 | }, | |||||
| 2574 | ||||||
| 2575 | quoted String: fu nction(str ) { | |||||
| 2576 | retu rn '"' + s tr | |||||
| 2577 | .r eplace(/\\ /g, '\\\\' ) | |||||
| 2578 | .r eplace(/"/ g, '\\"') | |||||
| 2579 | .r eplace(/\n /g, '\\n') | |||||
| 2580 | .r eplace(/\r /g, '\\r') | |||||
| 2581 | .r eplace(/\u 2028/g, '\ \u2028') // Per Ec ma-262 7.3 + 7.8.4 | |||||
| 2582 | .r eplace(/\u 2029/g, '\ \u2029') + '"'; | |||||
| 2583 | }, | |||||
| 2584 | ||||||
| 2585 | setupH elper: fun ction(para mSize, nam e, missing Params) { | |||||
| 2586 | var params = [ ], | |||||
| 2587 | paramsInit = this.se tupParams( paramSize, params, m issingPara ms); | |||||
| 2588 | var foundHelpe r = this.n ameLookup( 'helpers', name, 'he lper'); | |||||
| 2589 | ||||||
| 2590 | retu rn { | |||||
| 2591 | pa rams: para ms, | |||||
| 2592 | pa ramsInit: paramsInit , | |||||
| 2593 | na me: foundH elper, | |||||
| 2594 | ca llParams: ["depth0"] .concat(pa rams).join (", "), | |||||
| 2595 | he lperMissin gParams: m issingPara ms && ["de pth0", thi s.quotedSt ring(name) ].concat(p arams).joi n(", ") | |||||
| 2596 | }; | |||||
| 2597 | }, | |||||
| 2598 | ||||||
| 2599 | setupO ptions: fu nction(par amSize, pa rams) { | |||||
| 2600 | var options = [], contex ts = [], t ypes = [], param, in verse, pro gram; | |||||
| 2601 | ||||||
| 2602 | opti ons.push(" hash:" + t his.popSta ck()); | |||||
| 2603 | ||||||
| 2604 | if ( this.optio ns.stringP arams) { | |||||
| 2605 | op tions.push ("hashType s:" + this .popStack( )); | |||||
| 2606 | op tions.push ("hashCont exts:" + t his.popSta ck()); | |||||
| 2607 | } | |||||
| 2608 | ||||||
| 2609 | inve rse = this .popStack( ); | |||||
| 2610 | prog ram = this .popStack( ); | |||||
| 2611 | ||||||
| 2612 | // A void setti ng fn and inverse if neither a re set. Th is allows | |||||
| 2613 | // h elpers to do a check for `if ( options.fn )` | |||||
| 2614 | if ( program || inverse) { | |||||
| 2615 | if (!program ) { | |||||
| 2616 | this.conte xt.aliases .self = "t his"; | |||||
| 2617 | program = "self.noop "; | |||||
| 2618 | } | |||||
| 2619 | ||||||
| 2620 | if (!inverse ) { | |||||
| 2621 | this.conte xt.aliases .self = "t his"; | |||||
| 2622 | inverse = "self.noop "; | |||||
| 2623 | } | |||||
| 2624 | ||||||
| 2625 | op tions.push ("inverse: " + invers e); | |||||
| 2626 | op tions.push ("fn:" + p rogram); | |||||
| 2627 | } | |||||
| 2628 | ||||||
| 2629 | for( var i=0; i <paramSize ; i++) { | |||||
| 2630 | pa ram = this .popStack( ); | |||||
| 2631 | pa rams.push( param); | |||||
| 2632 | ||||||
| 2633 | if (this.opti ons.string Params) { | |||||
| 2634 | types.push (this.popS tack()); | |||||
| 2635 | contexts.p ush(this.p opStack()) ; | |||||
| 2636 | } | |||||
| 2637 | } | |||||
| 2638 | ||||||
| 2639 | if ( this.optio ns.stringP arams) { | |||||
| 2640 | op tions.push ("contexts :[" + cont exts.join( ",") + "]" ); | |||||
| 2641 | op tions.push ("types:[" + types.j oin(",") + "]"); | |||||
| 2642 | } | |||||
| 2643 | ||||||
| 2644 | if(t his.option s.data) { | |||||
| 2645 | op tions.push ("data:dat a"); | |||||
| 2646 | } | |||||
| 2647 | ||||||
| 2648 | retu rn options ; | |||||
| 2649 | }, | |||||
| 2650 | ||||||
| 2651 | // the params an d contexts arguments are passe d in array s | |||||
| 2652 | // to fill in | |||||
| 2653 | setupP arams: fun ction(para mSize, par ams, useRe gister) { | |||||
| 2654 | var options = '{' + this .setupOpti ons(paramS ize, param s).join(', ') + '}'; | |||||
| 2655 | ||||||
| 2656 | if ( useRegiste r) { | |||||
| 2657 | th is.useRegi ster('opti ons'); | |||||
| 2658 | pa rams.push( 'options') ; | |||||
| 2659 | re turn 'opti ons=' + op tions; | |||||
| 2660 | } el se { | |||||
| 2661 | pa rams.push( options); | |||||
| 2662 | re turn ''; | |||||
| 2663 | } | |||||
| 2664 | } | |||||
| 2665 | }; | |||||
| 2666 | ||||||
| 2667 | var rese rvedWords = ( | |||||
| 2668 | "break else new var" + | |||||
| 2669 | " case finally r eturn void " + | |||||
| 2670 | " catc h for swit ch while" + | |||||
| 2671 | " cont inue funct ion this w ith" + | |||||
| 2672 | " defa ult if thr ow" + | |||||
| 2673 | " dele te in try" + | |||||
| 2674 | " do i nstanceof typeof" + | |||||
| 2675 | " abst ract enum int short" + | |||||
| 2676 | " bool ean export interface static" + | |||||
| 2677 | " byte extends l ong super" + | |||||
| 2678 | " char final nat ive synchr onized" + | |||||
| 2679 | " clas s float pa ckage thro ws" + | |||||
| 2680 | " cons t goto pri vate trans ient" + | |||||
| 2681 | " debu gger imple ments prot ected vola tile" + | |||||
| 2682 | " doub le import public let yield" | |||||
| 2683 | ).split( " "); | |||||
| 2684 | ||||||
| 2685 | var comp ilerWords = JavaScri ptCompiler .RESERVED_ WORDS = {} ; | |||||
| 2686 | ||||||
| 2687 | for(var i=0, l=res ervedWords .length; i <l; i++) { | |||||
| 2688 | compil erWords[re servedWord s[i]] = tr ue; | |||||
| 2689 | } | |||||
| 2690 | ||||||
| 2691 | JavaScri ptCompiler .isValidJa vaScriptVa riableName = functio n(name) { | |||||
| 2692 | if(!Ja vaScriptCo mpiler.RES ERVED_WORD S[name] && /^[a-zA-Z _$][0-9a-z A-Z_$]*$/. test(name) ) { | |||||
| 2693 | retu rn true; | |||||
| 2694 | } | |||||
| 2695 | return false; | |||||
| 2696 | }; | |||||
| 2697 | ||||||
| 2698 | __export s__ = Java ScriptComp iler; | |||||
| 2699 | return _ _exports__ ; | |||||
| 2700 | })(__modul e2__, __mo dule5__); | |||||
| 2701 | ||||||
| 2702 | // handleb ars.js | |||||
| 2703 | var __modu le0__ = (f unction(__ dependency 1__, __dep endency2__ , __depend ency3__, _ _dependenc y4__, __de pendency5_ _) { | |||||
| 2704 | "use str ict"; | |||||
| 2705 | var __ex ports__; | |||||
| 2706 | /*global s Handleba rs: true * / | |||||
| 2707 | var Hand lebars = _ _dependenc y1__; | |||||
| 2708 | ||||||
| 2709 | // Compi ler import s | |||||
| 2710 | var AST = __depend ency2__; | |||||
| 2711 | var Pars er = __dep endency3__ .parser; | |||||
| 2712 | var pars e = __depe ndency3__. parse; | |||||
| 2713 | var Comp iler = __d ependency4 __.Compile r; | |||||
| 2714 | var comp ile = __de pendency4_ _.compile; | |||||
| 2715 | var prec ompile = _ _dependenc y4__.preco mpile; | |||||
| 2716 | var Java ScriptComp iler = __d ependency5 __; | |||||
| 2717 | ||||||
| 2718 | var _cre ate = Hand lebars.cre ate; | |||||
| 2719 | var crea te = funct ion() { | |||||
| 2720 | var hb = _create (); | |||||
| 2721 | ||||||
| 2722 | hb.com pile = fun ction(inpu t, options ) { | |||||
| 2723 | retu rn compile (input, op tions, hb) ; | |||||
| 2724 | }; | |||||
| 2725 | hb.pre compile = function ( input, opt ions) { | |||||
| 2726 | retu rn precomp ile(input, options, hb); | |||||
| 2727 | }; | |||||
| 2728 | ||||||
| 2729 | hb.AST = AST; | |||||
| 2730 | hb.Com piler = Co mpiler; | |||||
| 2731 | hb.Jav aScriptCom piler = Ja vaScriptCo mpiler; | |||||
| 2732 | hb.Par ser = Pars er; | |||||
| 2733 | hb.par se = parse ; | |||||
| 2734 | ||||||
| 2735 | return hb; | |||||
| 2736 | }; | |||||
| 2737 | ||||||
| 2738 | Handleba rs = creat e(); | |||||
| 2739 | Handleba rs.create = create; | |||||
| 2740 | ||||||
| 2741 | __export s__ = Hand lebars; | |||||
| 2742 | return _ _exports__ ; | |||||
| 2743 | })(__modul e1__, __mo dule7__, _ _module8__ , __module 10__, __mo dule11__); | |||||
| 2744 | ||||||
| 2745 | return _ _module0__ ; | |||||
| 2746 | })(); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.