PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.7
Pods – Custom Content Types and Fields v3.2.7
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / components / Templates / assets / js / handlebars2.js
pods / components / Templates / assets / js Last commit date
editor1.js 2 years ago handlebars.baldrick2.js 8 years ago handlebars2.js 8 years ago jquery.baldrick3.js 8 years ago panel.js 8 years ago scripts-pod_reference.js 2 years ago scripts-view_template.js 8 years ago
handlebars2.js
4295 lines
1 /*
2
3 Copyright (C) 2011 by Yehuda Katz
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22
23 */
24
25 // lib/handlebars/browser-prefix.js
26 var Handlebars = {};
27
28 (function ( Handlebars, undefined ) {
29 ;
30 // lib/handlebars/base.js
31
32 Handlebars.VERSION = "1.0.0";
33 Handlebars.COMPILER_REVISION = 4;
34
35 Handlebars.REVISION_CHANGES = {
36 1 : '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
37 2 : '== 1.0.0-rc.3', 3 : '== 1.0.0-rc.4', 4 : '>= 1.0.0'
38 };
39
40 Handlebars.helpers = {};
41 Handlebars.partials = {};
42
43 var toString = Object.prototype.toString, functionType = '[object Function]', objectType = '[object Object]';
44
45 Handlebars.registerHelper = function ( name, fn, inverse ) {
46 if ( toString.call( name ) === objectType ) {
47 if ( inverse || fn ) {
48 throw new Handlebars.Exception( 'Arg not supported with multiple helpers' );
49 }
50 Handlebars.Utils.extend( this.helpers, name );
51 }
52 else {
53 if ( inverse ) {
54 fn.not = inverse;
55 }
56 this.helpers[name] = fn;
57 }
58 };
59
60 Handlebars.registerPartial = function ( name, str ) {
61 if ( toString.call( name ) === objectType ) {
62 Handlebars.Utils.extend( this.partials, name );
63 }
64 else {
65 this.partials[name] = str;
66 }
67 };
68
69 Handlebars.registerHelper( 'helperMissing', function ( arg ) {
70 if ( arguments.length === 2 ) {
71 return undefined;
72 }
73 else {
74 throw new Error( "Missing helper: '" + arg + "'" );
75 }
76 } );
77
78 Handlebars.registerHelper( 'blockHelperMissing', function ( context, options ) {
79 var inverse = options.inverse || function () {
80 }, fn = options.fn;
81
82 var type = toString.call( context );
83
84 if ( type === functionType ) {
85 context = context.call( this );
86 }
87
88 if ( context === true ) {
89 return fn( this );
90 }
91 else {
92 if ( context === false || context == null ) {
93 return inverse( this );
94 }
95 else {
96 if ( type === "[object Array]" ) {
97 if ( context.length > 0 ) {
98 return Handlebars.helpers.each( context, options );
99 }
100 else {
101 return inverse( this );
102 }
103 }
104 else {
105 return fn( context );
106 }
107 }
108 }
109 } );
110
111 Handlebars.K = function () {
112 };
113
114 Handlebars.createFrame = Object.create || function ( object ) {
115 Handlebars.K.prototype = object;
116 var obj = new Handlebars.K();
117 Handlebars.K.prototype = null;
118 return obj;
119 };
120
121 Handlebars.logger = {
122 DEBUG : 0, INFO : 1, WARN : 2, ERROR : 3, level : 3,
123
124 methodMap : {0 : 'debug', 1 : 'info', 2 : 'warn', 3 : 'error'},
125
126 // can be overridden in the host environment
127 log : function ( level, obj ) {
128 if ( Handlebars.logger.level <= level ) {
129 var method = Handlebars.logger.methodMap[level];
130 if ( typeof console !== 'undefined' && console[method] ) {
131 console[method].call( console, obj );
132 }
133 }
134 }
135 };
136
137 Handlebars.log = function ( level, obj ) {
138 Handlebars.logger.log( level, obj );
139 };
140
141 Handlebars.registerHelper( 'each', function ( context, options ) {
142 var fn = options.fn, inverse = options.inverse;
143 var i = 0, ret = "", data;
144
145 var type = toString.call( context );
146 if ( type === functionType ) {
147 context = context.call( this );
148 }
149
150 if ( options.data ) {
151 data = Handlebars.createFrame( options.data );
152 }
153
154 if ( context && typeof context === 'object' ) {
155 if ( context instanceof Array ) {
156 for ( var j = context.length; i < j; i++ ) {
157 if ( data ) {
158 data.index = i;
159 }
160 ret = ret + fn( context[i], {data : data} );
161 }
162 }
163 else {
164 for ( var key in context ) {
165 if ( context.hasOwnProperty( key ) ) {
166 if ( data ) {
167 data.key = key;
168 }
169 ret = ret + fn( context[key], {data : data} );
170 i++;
171 }
172 }
173 }
174 }
175
176 if ( i === 0 ) {
177 ret = inverse( this );
178 }
179
180 return ret;
181 } );
182
183 Handlebars.registerHelper( 'if', function ( conditional, options ) {
184 var type = toString.call( conditional );
185 if ( type === functionType ) {
186 conditional = conditional.call( this );
187 }
188
189 if ( !conditional || Handlebars.Utils.isEmpty( conditional ) ) {
190 return options.inverse( this );
191 }
192 else {
193 return options.fn( this );
194 }
195 } );
196
197 Handlebars.registerHelper( 'unless', function ( conditional, options ) {
198 return Handlebars.helpers['if'].call( this, conditional, {fn : options.inverse, inverse : options.fn} );
199 } );
200
201 Handlebars.registerHelper( 'with', function ( context, options ) {
202 var type = toString.call( context );
203 if ( type === functionType ) {
204 context = context.call( this );
205 }
206
207 if ( !Handlebars.Utils.isEmpty( context ) ) {
208 return options.fn( context );
209 }
210 } );
211
212 Handlebars.registerHelper( 'log', function ( context, options ) {
213 var level = options.data && options.data.level != null ? parseInt( options.data.level, 10 ) : 1;
214 Handlebars.log( level, context );
215 } );
216 ;
217 // lib/handlebars/compiler/parser.js
218 /* Jison generated parser */
219 var handlebars = (function () {
220 var parser = {
221 trace : function trace() {
222 }, yy : {}, symbols_ : {
223 "error" : 2,
224 "root" : 3,
225 "program" : 4,
226 "EOF" : 5,
227 "simpleInverse" : 6,
228 "statements" : 7,
229 "statement" : 8,
230 "openInverse" : 9,
231 "closeBlock" : 10,
232 "openBlock" : 11,
233 "mustache" : 12,
234 "partial" : 13,
235 "CONTENT" : 14,
236 "COMMENT" : 15,
237 "OPEN_BLOCK" : 16,
238 "inMustache" : 17,
239 "CLOSE" : 18,
240 "OPEN_INVERSE" : 19,
241 "OPEN_ENDBLOCK" : 20,
242 "path" : 21,
243 "OPEN" : 22,
244 "OPEN_UNESCAPED" : 23,
245 "CLOSE_UNESCAPED" : 24,
246 "OPEN_PARTIAL" : 25,
247 "partialName" : 26,
248 "params" : 27,
249 "hash" : 28,
250 "dataName" : 29,
251 "param" : 30,
252 "STRING" : 31,
253 "INTEGER" : 32,
254 "BOOLEAN" : 33,
255 "hashSegments" : 34,
256 "hashSegment" : 35,
257 "ID" : 36,
258 "EQUALS" : 37,
259 "DATA" : 38,
260 "pathSegments" : 39,
261 "SEP" : 40,
262 "$accept" : 0,
263 "$end" : 1
264 }, terminals_ : {
265 2 : "error",
266 5 : "EOF",
267 14 : "CONTENT",
268 15 : "COMMENT",
269 16 : "OPEN_BLOCK",
270 18 : "CLOSE",
271 19 : "OPEN_INVERSE",
272 20 : "OPEN_ENDBLOCK",
273 22 : "OPEN",
274 23 : "OPEN_UNESCAPED",
275 24 : "CLOSE_UNESCAPED",
276 25 : "OPEN_PARTIAL",
277 31 : "STRING",
278 32 : "INTEGER",
279 33 : "BOOLEAN",
280 36 : "ID",
281 37 : "EQUALS",
282 38 : "DATA",
283 40 : "SEP"
284 }, productions_ : [
285 0,
286 [
287 3,
288 2
289 ],
290 [
291 4,
292 2
293 ],
294 [
295 4,
296 3
297 ],
298 [
299 4,
300 2
301 ],
302 [
303 4,
304 1
305 ],
306 [
307 4,
308 1
309 ],
310 [
311 4,
312 0
313 ],
314 [
315 7,
316 1
317 ],
318 [
319 7,
320 2
321 ],
322 [
323 8,
324 3
325 ],
326 [
327 8,
328 3
329 ],
330 [
331 8,
332 1
333 ],
334 [
335 8,
336 1
337 ],
338 [
339 8,
340 1
341 ],
342 [
343 8,
344 1
345 ],
346 [
347 11,
348 3
349 ],
350 [
351 9,
352 3
353 ],
354 [
355 10,
356 3
357 ],
358 [
359 12,
360 3
361 ],
362 [
363 12,
364 3
365 ],
366 [
367 13,
368 3
369 ],
370 [
371 13,
372 4
373 ],
374 [
375 6,
376 2
377 ],
378 [
379 17,
380 3
381 ],
382 [
383 17,
384 2
385 ],
386 [
387 17,
388 2
389 ],
390 [
391 17,
392 1
393 ],
394 [
395 17,
396 1
397 ],
398 [
399 27,
400 2
401 ],
402 [
403 27,
404 1
405 ],
406 [
407 30,
408 1
409 ],
410 [
411 30,
412 1
413 ],
414 [
415 30,
416 1
417 ],
418 [
419 30,
420 1
421 ],
422 [
423 30,
424 1
425 ],
426 [
427 28,
428 1
429 ],
430 [
431 34,
432 2
433 ],
434 [
435 34,
436 1
437 ],
438 [
439 35,
440 3
441 ],
442 [
443 35,
444 3
445 ],
446 [
447 35,
448 3
449 ],
450 [
451 35,
452 3
453 ],
454 [
455 35,
456 3
457 ],
458 [
459 26,
460 1
461 ],
462 [
463 26,
464 1
465 ],
466 [
467 26,
468 1
469 ],
470 [
471 29,
472 2
473 ],
474 [
475 21,
476 1
477 ],
478 [
479 39,
480 3
481 ],
482 [
483 39,
484 1
485 ]
486 ], performAction : function anonymous( yytext, yyleng, yylineno, yy, yystate, $$, _$ ) {
487
488 var $0 = $$.length - 1;
489 switch ( yystate ) {
490 case 1:
491 return $$[$0 - 1];
492 break;
493 case 2:
494 this.$ = new yy.ProgramNode( [], $$[$0] );
495 break;
496 case 3:
497 this.$ = new yy.ProgramNode( $$[$0 - 2], $$[$0] );
498 break;
499 case 4:
500 this.$ = new yy.ProgramNode( $$[$0 - 1], [] );
501 break;
502 case 5:
503 this.$ = new yy.ProgramNode( $$[$0] );
504 break;
505 case 6:
506 this.$ = new yy.ProgramNode( [], [] );
507 break;
508 case 7:
509 this.$ = new yy.ProgramNode( [] );
510 break;
511 case 8:
512 this.$ = [$$[$0]];
513 break;
514 case 9:
515 $$[$0 - 1].push( $$[$0] );
516 this.$ = $$[$0 - 1];
517 break;
518 case 10:
519 this.$ = new yy.BlockNode( $$[$0 - 2], $$[$0 - 1].inverse, $$[$0 - 1], $$[$0] );
520 break;
521 case 11:
522 this.$ = new yy.BlockNode( $$[$0 - 2], $$[$0 - 1], $$[$0 - 1].inverse, $$[$0] );
523 break;
524 case 12:
525 this.$ = $$[$0];
526 break;
527 case 13:
528 this.$ = $$[$0];
529 break;
530 case 14:
531 this.$ = new yy.ContentNode( $$[$0] );
532 break;
533 case 15:
534 this.$ = new yy.CommentNode( $$[$0] );
535 break;
536 case 16:
537 this.$ = new yy.MustacheNode( $$[$0 - 1][0], $$[$0 - 1][1] );
538 break;
539 case 17:
540 this.$ = new yy.MustacheNode( $$[$0 - 1][0], $$[$0 - 1][1] );
541 break;
542 case 18:
543 this.$ = $$[$0 - 1];
544 break;
545 case 19:
546 // Parsing out the '&' escape token at this level saves ~500 bytes after min due to the removal of one parser node.
547 this.$ = new yy.MustacheNode( $$[$0 - 1][0], $$[$0 - 1][1], $$[$0 - 2][2] === '&' );
548
549 break;
550 case 20:
551 this.$ = new yy.MustacheNode( $$[$0 - 1][0], $$[$0 - 1][1], true );
552 break;
553 case 21:
554 this.$ = new yy.PartialNode( $$[$0 - 1] );
555 break;
556 case 22:
557 this.$ = new yy.PartialNode( $$[$0 - 2], $$[$0 - 1] );
558 break;
559 case 23:
560 break;
561 case 24:
562 this.$ = [
563 [$$[$0 - 2]].concat( $$[$0 - 1] ),
564 $$[$0]
565 ];
566 break;
567 case 25:
568 this.$ = [
569 [$$[$0 - 1]].concat( $$[$0] ),
570 null
571 ];
572 break;
573 case 26:
574 this.$ = [
575 [$$[$0 - 1]],
576 $$[$0]
577 ];
578 break;
579 case 27:
580 this.$ = [
581 [$$[$0]],
582 null
583 ];
584 break;
585 case 28:
586 this.$ = [
587 [$$[$0]],
588 null
589 ];
590 break;
591 case 29:
592 $$[$0 - 1].push( $$[$0] );
593 this.$ = $$[$0 - 1];
594 break;
595 case 30:
596 this.$ = [$$[$0]];
597 break;
598 case 31:
599 this.$ = $$[$0];
600 break;
601 case 32:
602 this.$ = new yy.StringNode( $$[$0] );
603 break;
604 case 33:
605 this.$ = new yy.IntegerNode( $$[$0] );
606 break;
607 case 34:
608 this.$ = new yy.BooleanNode( $$[$0] );
609 break;
610 case 35:
611 this.$ = $$[$0];
612 break;
613 case 36:
614 this.$ = new yy.HashNode( $$[$0] );
615 break;
616 case 37:
617 $$[$0 - 1].push( $$[$0] );
618 this.$ = $$[$0 - 1];
619 break;
620 case 38:
621 this.$ = [$$[$0]];
622 break;
623 case 39:
624 this.$ = [
625 $$[$0 - 2],
626 $$[$0]
627 ];
628 break;
629 case 40:
630 this.$ = [
631 $$[$0 - 2],
632 new yy.StringNode( $$[$0] )
633 ];
634 break;
635 case 41:
636 this.$ = [
637 $$[$0 - 2],
638 new yy.IntegerNode( $$[$0] )
639 ];
640 break;
641 case 42:
642 this.$ = [
643 $$[$0 - 2],
644 new yy.BooleanNode( $$[$0] )
645 ];
646 break;
647 case 43:
648 this.$ = [
649 $$[$0 - 2],
650 $$[$0]
651 ];
652 break;
653 case 44:
654 this.$ = new yy.PartialNameNode( $$[$0] );
655 break;
656 case 45:
657 this.$ = new yy.PartialNameNode( new yy.StringNode( $$[$0] ) );
658 break;
659 case 46:
660 this.$ = new yy.PartialNameNode( new yy.IntegerNode( $$[$0] ) );
661 break;
662 case 47:
663 this.$ = new yy.DataNode( $$[$0] );
664 break;
665 case 48:
666 this.$ = new yy.IdNode( $$[$0] );
667 break;
668 case 49:
669 $$[$0 - 2].push( {part : $$[$0], separator : $$[$0 - 1]} );
670 this.$ = $$[$0 - 2];
671 break;
672 case 50:
673 this.$ = [{part : $$[$0]}];
674 break;
675 }
676 }, table : [
677 {
678 3 : 1, 4 : 2, 5 : [
679 2,
680 7
681 ], 6 : 3, 7 : 4, 8 : 6, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
682 1,
683 11
684 ], 15 : [
685 1,
686 12
687 ], 16 : [
688 1,
689 13
690 ], 19 : [
691 1,
692 5
693 ], 22 : [
694 1,
695 14
696 ], 23 : [
697 1,
698 15
699 ], 25 : [
700 1,
701 16
702 ]
703 },
704 {1 : [3]},
705 {
706 5 : [
707 1,
708 17
709 ]
710 },
711 {
712 5 : [
713 2,
714 6
715 ], 7 : 18, 8 : 6, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
716 1,
717 11
718 ], 15 : [
719 1,
720 12
721 ], 16 : [
722 1,
723 13
724 ], 19 : [
725 1,
726 19
727 ], 20 : [
728 2,
729 6
730 ], 22 : [
731 1,
732 14
733 ], 23 : [
734 1,
735 15
736 ], 25 : [
737 1,
738 16
739 ]
740 },
741 {
742 5 : [
743 2,
744 5
745 ], 6 : 20, 8 : 21, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
746 1,
747 11
748 ], 15 : [
749 1,
750 12
751 ], 16 : [
752 1,
753 13
754 ], 19 : [
755 1,
756 5
757 ], 20 : [
758 2,
759 5
760 ], 22 : [
761 1,
762 14
763 ], 23 : [
764 1,
765 15
766 ], 25 : [
767 1,
768 16
769 ]
770 },
771 {
772 17 : 23, 18 : [
773 1,
774 22
775 ], 21 : 24, 29 : 25, 36 : [
776 1,
777 28
778 ], 38 : [
779 1,
780 27
781 ], 39 : 26
782 },
783 {
784 5 : [
785 2,
786 8
787 ], 14 : [
788 2,
789 8
790 ], 15 : [
791 2,
792 8
793 ], 16 : [
794 2,
795 8
796 ], 19 : [
797 2,
798 8
799 ], 20 : [
800 2,
801 8
802 ], 22 : [
803 2,
804 8
805 ], 23 : [
806 2,
807 8
808 ], 25 : [
809 2,
810 8
811 ]
812 },
813 {
814 4 : 29, 6 : 3, 7 : 4, 8 : 6, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
815 1,
816 11
817 ], 15 : [
818 1,
819 12
820 ], 16 : [
821 1,
822 13
823 ], 19 : [
824 1,
825 5
826 ], 20 : [
827 2,
828 7
829 ], 22 : [
830 1,
831 14
832 ], 23 : [
833 1,
834 15
835 ], 25 : [
836 1,
837 16
838 ]
839 },
840 {
841 4 : 30, 6 : 3, 7 : 4, 8 : 6, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
842 1,
843 11
844 ], 15 : [
845 1,
846 12
847 ], 16 : [
848 1,
849 13
850 ], 19 : [
851 1,
852 5
853 ], 20 : [
854 2,
855 7
856 ], 22 : [
857 1,
858 14
859 ], 23 : [
860 1,
861 15
862 ], 25 : [
863 1,
864 16
865 ]
866 },
867 {
868 5 : [
869 2,
870 12
871 ], 14 : [
872 2,
873 12
874 ], 15 : [
875 2,
876 12
877 ], 16 : [
878 2,
879 12
880 ], 19 : [
881 2,
882 12
883 ], 20 : [
884 2,
885 12
886 ], 22 : [
887 2,
888 12
889 ], 23 : [
890 2,
891 12
892 ], 25 : [
893 2,
894 12
895 ]
896 },
897 {
898 5 : [
899 2,
900 13
901 ], 14 : [
902 2,
903 13
904 ], 15 : [
905 2,
906 13
907 ], 16 : [
908 2,
909 13
910 ], 19 : [
911 2,
912 13
913 ], 20 : [
914 2,
915 13
916 ], 22 : [
917 2,
918 13
919 ], 23 : [
920 2,
921 13
922 ], 25 : [
923 2,
924 13
925 ]
926 },
927 {
928 5 : [
929 2,
930 14
931 ], 14 : [
932 2,
933 14
934 ], 15 : [
935 2,
936 14
937 ], 16 : [
938 2,
939 14
940 ], 19 : [
941 2,
942 14
943 ], 20 : [
944 2,
945 14
946 ], 22 : [
947 2,
948 14
949 ], 23 : [
950 2,
951 14
952 ], 25 : [
953 2,
954 14
955 ]
956 },
957 {
958 5 : [
959 2,
960 15
961 ], 14 : [
962 2,
963 15
964 ], 15 : [
965 2,
966 15
967 ], 16 : [
968 2,
969 15
970 ], 19 : [
971 2,
972 15
973 ], 20 : [
974 2,
975 15
976 ], 22 : [
977 2,
978 15
979 ], 23 : [
980 2,
981 15
982 ], 25 : [
983 2,
984 15
985 ]
986 },
987 {
988 17 : 31, 21 : 24, 29 : 25, 36 : [
989 1,
990 28
991 ], 38 : [
992 1,
993 27
994 ], 39 : 26
995 },
996 {
997 17 : 32, 21 : 24, 29 : 25, 36 : [
998 1,
999 28
1000 ], 38 : [
1001 1,
1002 27
1003 ], 39 : 26
1004 },
1005 {
1006 17 : 33, 21 : 24, 29 : 25, 36 : [
1007 1,
1008 28
1009 ], 38 : [
1010 1,
1011 27
1012 ], 39 : 26
1013 },
1014 {
1015 21 : 35, 26 : 34, 31 : [
1016 1,
1017 36
1018 ], 32 : [
1019 1,
1020 37
1021 ], 36 : [
1022 1,
1023 28
1024 ], 39 : 26
1025 },
1026 {
1027 1 : [
1028 2,
1029 1
1030 ]
1031 },
1032 {
1033 5 : [
1034 2,
1035 2
1036 ], 8 : 21, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
1037 1,
1038 11
1039 ], 15 : [
1040 1,
1041 12
1042 ], 16 : [
1043 1,
1044 13
1045 ], 19 : [
1046 1,
1047 19
1048 ], 20 : [
1049 2,
1050 2
1051 ], 22 : [
1052 1,
1053 14
1054 ], 23 : [
1055 1,
1056 15
1057 ], 25 : [
1058 1,
1059 16
1060 ]
1061 },
1062 {
1063 17 : 23, 21 : 24, 29 : 25, 36 : [
1064 1,
1065 28
1066 ], 38 : [
1067 1,
1068 27
1069 ], 39 : 26
1070 },
1071 {
1072 5 : [
1073 2,
1074 4
1075 ], 7 : 38, 8 : 6, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
1076 1,
1077 11
1078 ], 15 : [
1079 1,
1080 12
1081 ], 16 : [
1082 1,
1083 13
1084 ], 19 : [
1085 1,
1086 19
1087 ], 20 : [
1088 2,
1089 4
1090 ], 22 : [
1091 1,
1092 14
1093 ], 23 : [
1094 1,
1095 15
1096 ], 25 : [
1097 1,
1098 16
1099 ]
1100 },
1101 {
1102 5 : [
1103 2,
1104 9
1105 ], 14 : [
1106 2,
1107 9
1108 ], 15 : [
1109 2,
1110 9
1111 ], 16 : [
1112 2,
1113 9
1114 ], 19 : [
1115 2,
1116 9
1117 ], 20 : [
1118 2,
1119 9
1120 ], 22 : [
1121 2,
1122 9
1123 ], 23 : [
1124 2,
1125 9
1126 ], 25 : [
1127 2,
1128 9
1129 ]
1130 },
1131 {
1132 5 : [
1133 2,
1134 23
1135 ], 14 : [
1136 2,
1137 23
1138 ], 15 : [
1139 2,
1140 23
1141 ], 16 : [
1142 2,
1143 23
1144 ], 19 : [
1145 2,
1146 23
1147 ], 20 : [
1148 2,
1149 23
1150 ], 22 : [
1151 2,
1152 23
1153 ], 23 : [
1154 2,
1155 23
1156 ], 25 : [
1157 2,
1158 23
1159 ]
1160 },
1161 {
1162 18 : [
1163 1,
1164 39
1165 ]
1166 },
1167 {
1168 18 : [
1169 2,
1170 27
1171 ], 21 : 44, 24 : [
1172 2,
1173 27
1174 ], 27 : 40, 28 : 41, 29 : 48, 30 : 42, 31 : [
1175 1,
1176 45
1177 ], 32 : [
1178 1,
1179 46
1180 ], 33 : [
1181 1,
1182 47
1183 ], 34 : 43, 35 : 49, 36 : [
1184 1,
1185 50
1186 ], 38 : [
1187 1,
1188 27
1189 ], 39 : 26
1190 },
1191 {
1192 18 : [
1193 2,
1194 28
1195 ], 24 : [
1196 2,
1197 28
1198 ]
1199 },
1200 {
1201 18 : [
1202 2,
1203 48
1204 ], 24 : [
1205 2,
1206 48
1207 ], 31 : [
1208 2,
1209 48
1210 ], 32 : [
1211 2,
1212 48
1213 ], 33 : [
1214 2,
1215 48
1216 ], 36 : [
1217 2,
1218 48
1219 ], 38 : [
1220 2,
1221 48
1222 ], 40 : [
1223 1,
1224 51
1225 ]
1226 },
1227 {
1228 21 : 52, 36 : [
1229 1,
1230 28
1231 ], 39 : 26
1232 },
1233 {
1234 18 : [
1235 2,
1236 50
1237 ], 24 : [
1238 2,
1239 50
1240 ], 31 : [
1241 2,
1242 50
1243 ], 32 : [
1244 2,
1245 50
1246 ], 33 : [
1247 2,
1248 50
1249 ], 36 : [
1250 2,
1251 50
1252 ], 38 : [
1253 2,
1254 50
1255 ], 40 : [
1256 2,
1257 50
1258 ]
1259 },
1260 {
1261 10 : 53, 20 : [
1262 1,
1263 54
1264 ]
1265 },
1266 {
1267 10 : 55, 20 : [
1268 1,
1269 54
1270 ]
1271 },
1272 {
1273 18 : [
1274 1,
1275 56
1276 ]
1277 },
1278 {
1279 18 : [
1280 1,
1281 57
1282 ]
1283 },
1284 {
1285 24 : [
1286 1,
1287 58
1288 ]
1289 },
1290 {
1291 18 : [
1292 1,
1293 59
1294 ], 21 : 60, 36 : [
1295 1,
1296 28
1297 ], 39 : 26
1298 },
1299 {
1300 18 : [
1301 2,
1302 44
1303 ], 36 : [
1304 2,
1305 44
1306 ]
1307 },
1308 {
1309 18 : [
1310 2,
1311 45
1312 ], 36 : [
1313 2,
1314 45
1315 ]
1316 },
1317 {
1318 18 : [
1319 2,
1320 46
1321 ], 36 : [
1322 2,
1323 46
1324 ]
1325 },
1326 {
1327 5 : [
1328 2,
1329 3
1330 ], 8 : 21, 9 : 7, 11 : 8, 12 : 9, 13 : 10, 14 : [
1331 1,
1332 11
1333 ], 15 : [
1334 1,
1335 12
1336 ], 16 : [
1337 1,
1338 13
1339 ], 19 : [
1340 1,
1341 19
1342 ], 20 : [
1343 2,
1344 3
1345 ], 22 : [
1346 1,
1347 14
1348 ], 23 : [
1349 1,
1350 15
1351 ], 25 : [
1352 1,
1353 16
1354 ]
1355 },
1356 {
1357 14 : [
1358 2,
1359 17
1360 ], 15 : [
1361 2,
1362 17
1363 ], 16 : [
1364 2,
1365 17
1366 ], 19 : [
1367 2,
1368 17
1369 ], 20 : [
1370 2,
1371 17
1372 ], 22 : [
1373 2,
1374 17
1375 ], 23 : [
1376 2,
1377 17
1378 ], 25 : [
1379 2,
1380 17
1381 ]
1382 },
1383 {
1384 18 : [
1385 2,
1386 25
1387 ], 21 : 44, 24 : [
1388 2,
1389 25
1390 ], 28 : 61, 29 : 48, 30 : 62, 31 : [
1391 1,
1392 45
1393 ], 32 : [
1394 1,
1395 46
1396 ], 33 : [
1397 1,
1398 47
1399 ], 34 : 43, 35 : 49, 36 : [
1400 1,
1401 50
1402 ], 38 : [
1403 1,
1404 27
1405 ], 39 : 26
1406 },
1407 {
1408 18 : [
1409 2,
1410 26
1411 ], 24 : [
1412 2,
1413 26
1414 ]
1415 },
1416 {
1417 18 : [
1418 2,
1419 30
1420 ], 24 : [
1421 2,
1422 30
1423 ], 31 : [
1424 2,
1425 30
1426 ], 32 : [
1427 2,
1428 30
1429 ], 33 : [
1430 2,
1431 30
1432 ], 36 : [
1433 2,
1434 30
1435 ], 38 : [
1436 2,
1437 30
1438 ]
1439 },
1440 {
1441 18 : [
1442 2,
1443 36
1444 ], 24 : [
1445 2,
1446 36
1447 ], 35 : 63, 36 : [
1448 1,
1449 64
1450 ]
1451 },
1452 {
1453 18 : [
1454 2,
1455 31
1456 ], 24 : [
1457 2,
1458 31
1459 ], 31 : [
1460 2,
1461 31
1462 ], 32 : [
1463 2,
1464 31
1465 ], 33 : [
1466 2,
1467 31
1468 ], 36 : [
1469 2,
1470 31
1471 ], 38 : [
1472 2,
1473 31
1474 ]
1475 },
1476 {
1477 18 : [
1478 2,
1479 32
1480 ], 24 : [
1481 2,
1482 32
1483 ], 31 : [
1484 2,
1485 32
1486 ], 32 : [
1487 2,
1488 32
1489 ], 33 : [
1490 2,
1491 32
1492 ], 36 : [
1493 2,
1494 32
1495 ], 38 : [
1496 2,
1497 32
1498 ]
1499 },
1500 {
1501 18 : [
1502 2,
1503 33
1504 ], 24 : [
1505 2,
1506 33
1507 ], 31 : [
1508 2,
1509 33
1510 ], 32 : [
1511 2,
1512 33
1513 ], 33 : [
1514 2,
1515 33
1516 ], 36 : [
1517 2,
1518 33
1519 ], 38 : [
1520 2,
1521 33
1522 ]
1523 },
1524 {
1525 18 : [
1526 2,
1527 34
1528 ], 24 : [
1529 2,
1530 34
1531 ], 31 : [
1532 2,
1533 34
1534 ], 32 : [
1535 2,
1536 34
1537 ], 33 : [
1538 2,
1539 34
1540 ], 36 : [
1541 2,
1542 34
1543 ], 38 : [
1544 2,
1545 34
1546 ]
1547 },
1548 {
1549 18 : [
1550 2,
1551 35
1552 ], 24 : [
1553 2,
1554 35
1555 ], 31 : [
1556 2,
1557 35
1558 ], 32 : [
1559 2,
1560 35
1561 ], 33 : [
1562 2,
1563 35
1564 ], 36 : [
1565 2,
1566 35
1567 ], 38 : [
1568 2,
1569 35
1570 ]
1571 },
1572 {
1573 18 : [
1574 2,
1575 38
1576 ], 24 : [
1577 2,
1578 38
1579 ], 36 : [
1580 2,
1581 38
1582 ]
1583 },
1584 {
1585 18 : [
1586 2,
1587 50
1588 ], 24 : [
1589 2,
1590 50
1591 ], 31 : [
1592 2,
1593 50
1594 ], 32 : [
1595 2,
1596 50
1597 ], 33 : [
1598 2,
1599 50
1600 ], 36 : [
1601 2,
1602 50
1603 ], 37 : [
1604 1,
1605 65
1606 ], 38 : [
1607 2,
1608 50
1609 ], 40 : [
1610 2,
1611 50
1612 ]
1613 },
1614 {
1615 36 : [
1616 1,
1617 66
1618 ]
1619 },
1620 {
1621 18 : [
1622 2,
1623 47
1624 ], 24 : [
1625 2,
1626 47
1627 ], 31 : [
1628 2,
1629 47
1630 ], 32 : [
1631 2,
1632 47
1633 ], 33 : [
1634 2,
1635 47
1636 ], 36 : [
1637 2,
1638 47
1639 ], 38 : [
1640 2,
1641 47
1642 ]
1643 },
1644 {
1645 5 : [
1646 2,
1647 10
1648 ], 14 : [
1649 2,
1650 10
1651 ], 15 : [
1652 2,
1653 10
1654 ], 16 : [
1655 2,
1656 10
1657 ], 19 : [
1658 2,
1659 10
1660 ], 20 : [
1661 2,
1662 10
1663 ], 22 : [
1664 2,
1665 10
1666 ], 23 : [
1667 2,
1668 10
1669 ], 25 : [
1670 2,
1671 10
1672 ]
1673 },
1674 {
1675 21 : 67, 36 : [
1676 1,
1677 28
1678 ], 39 : 26
1679 },
1680 {
1681 5 : [
1682 2,
1683 11
1684 ], 14 : [
1685 2,
1686 11
1687 ], 15 : [
1688 2,
1689 11
1690 ], 16 : [
1691 2,
1692 11
1693 ], 19 : [
1694 2,
1695 11
1696 ], 20 : [
1697 2,
1698 11
1699 ], 22 : [
1700 2,
1701 11
1702 ], 23 : [
1703 2,
1704 11
1705 ], 25 : [
1706 2,
1707 11
1708 ]
1709 },
1710 {
1711 14 : [
1712 2,
1713 16
1714 ], 15 : [
1715 2,
1716 16
1717 ], 16 : [
1718 2,
1719 16
1720 ], 19 : [
1721 2,
1722 16
1723 ], 20 : [
1724 2,
1725 16
1726 ], 22 : [
1727 2,
1728 16
1729 ], 23 : [
1730 2,
1731 16
1732 ], 25 : [
1733 2,
1734 16
1735 ]
1736 },
1737 {
1738 5 : [
1739 2,
1740 19
1741 ], 14 : [
1742 2,
1743 19
1744 ], 15 : [
1745 2,
1746 19
1747 ], 16 : [
1748 2,
1749 19
1750 ], 19 : [
1751 2,
1752 19
1753 ], 20 : [
1754 2,
1755 19
1756 ], 22 : [
1757 2,
1758 19
1759 ], 23 : [
1760 2,
1761 19
1762 ], 25 : [
1763 2,
1764 19
1765 ]
1766 },
1767 {
1768 5 : [
1769 2,
1770 20
1771 ], 14 : [
1772 2,
1773 20
1774 ], 15 : [
1775 2,
1776 20
1777 ], 16 : [
1778 2,
1779 20
1780 ], 19 : [
1781 2,
1782 20
1783 ], 20 : [
1784 2,
1785 20
1786 ], 22 : [
1787 2,
1788 20
1789 ], 23 : [
1790 2,
1791 20
1792 ], 25 : [
1793 2,
1794 20
1795 ]
1796 },
1797 {
1798 5 : [
1799 2,
1800 21
1801 ], 14 : [
1802 2,
1803 21
1804 ], 15 : [
1805 2,
1806 21
1807 ], 16 : [
1808 2,
1809 21
1810 ], 19 : [
1811 2,
1812 21
1813 ], 20 : [
1814 2,
1815 21
1816 ], 22 : [
1817 2,
1818 21
1819 ], 23 : [
1820 2,
1821 21
1822 ], 25 : [
1823 2,
1824 21
1825 ]
1826 },
1827 {
1828 18 : [
1829 1,
1830 68
1831 ]
1832 },
1833 {
1834 18 : [
1835 2,
1836 24
1837 ], 24 : [
1838 2,
1839 24
1840 ]
1841 },
1842 {
1843 18 : [
1844 2,
1845 29
1846 ], 24 : [
1847 2,
1848 29
1849 ], 31 : [
1850 2,
1851 29
1852 ], 32 : [
1853 2,
1854 29
1855 ], 33 : [
1856 2,
1857 29
1858 ], 36 : [
1859 2,
1860 29
1861 ], 38 : [
1862 2,
1863 29
1864 ]
1865 },
1866 {
1867 18 : [
1868 2,
1869 37
1870 ], 24 : [
1871 2,
1872 37
1873 ], 36 : [
1874 2,
1875 37
1876 ]
1877 },
1878 {
1879 37 : [
1880 1,
1881 65
1882 ]
1883 },
1884 {
1885 21 : 69, 29 : 73, 31 : [
1886 1,
1887 70
1888 ], 32 : [
1889 1,
1890 71
1891 ], 33 : [
1892 1,
1893 72
1894 ], 36 : [
1895 1,
1896 28
1897 ], 38 : [
1898 1,
1899 27
1900 ], 39 : 26
1901 },
1902 {
1903 18 : [
1904 2,
1905 49
1906 ], 24 : [
1907 2,
1908 49
1909 ], 31 : [
1910 2,
1911 49
1912 ], 32 : [
1913 2,
1914 49
1915 ], 33 : [
1916 2,
1917 49
1918 ], 36 : [
1919 2,
1920 49
1921 ], 38 : [
1922 2,
1923 49
1924 ], 40 : [
1925 2,
1926 49
1927 ]
1928 },
1929 {
1930 18 : [
1931 1,
1932 74
1933 ]
1934 },
1935 {
1936 5 : [
1937 2,
1938 22
1939 ], 14 : [
1940 2,
1941 22
1942 ], 15 : [
1943 2,
1944 22
1945 ], 16 : [
1946 2,
1947 22
1948 ], 19 : [
1949 2,
1950 22
1951 ], 20 : [
1952 2,
1953 22
1954 ], 22 : [
1955 2,
1956 22
1957 ], 23 : [
1958 2,
1959 22
1960 ], 25 : [
1961 2,
1962 22
1963 ]
1964 },
1965 {
1966 18 : [
1967 2,
1968 39
1969 ], 24 : [
1970 2,
1971 39
1972 ], 36 : [
1973 2,
1974 39
1975 ]
1976 },
1977 {
1978 18 : [
1979 2,
1980 40
1981 ], 24 : [
1982 2,
1983 40
1984 ], 36 : [
1985 2,
1986 40
1987 ]
1988 },
1989 {
1990 18 : [
1991 2,
1992 41
1993 ], 24 : [
1994 2,
1995 41
1996 ], 36 : [
1997 2,
1998 41
1999 ]
2000 },
2001 {
2002 18 : [
2003 2,
2004 42
2005 ], 24 : [
2006 2,
2007 42
2008 ], 36 : [
2009 2,
2010 42
2011 ]
2012 },
2013 {
2014 18 : [
2015 2,
2016 43
2017 ], 24 : [
2018 2,
2019 43
2020 ], 36 : [
2021 2,
2022 43
2023 ]
2024 },
2025 {
2026 5 : [
2027 2,
2028 18
2029 ], 14 : [
2030 2,
2031 18
2032 ], 15 : [
2033 2,
2034 18
2035 ], 16 : [
2036 2,
2037 18
2038 ], 19 : [
2039 2,
2040 18
2041 ], 20 : [
2042 2,
2043 18
2044 ], 22 : [
2045 2,
2046 18
2047 ], 23 : [
2048 2,
2049 18
2050 ], 25 : [
2051 2,
2052 18
2053 ]
2054 }
2055 ], defaultActions : {
2056 17 : [
2057 2,
2058 1
2059 ]
2060 }, parseError : function parseError( str, hash ) {
2061 throw new Error( str );
2062 }, parse : function parse( input ) {
2063 var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "",
2064 yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
2065 this.lexer.setInput( input );
2066 this.lexer.yy = this.yy;
2067 this.yy.lexer = this.lexer;
2068 this.yy.parser = this;
2069 if ( typeof this.lexer.yylloc == "undefined" ) {
2070 this.lexer.yylloc = {};
2071 }
2072 var yyloc = this.lexer.yylloc;
2073 lstack.push( yyloc );
2074 var ranges = this.lexer.options && this.lexer.options.ranges;
2075 if ( typeof this.yy.parseError === "function" ) {
2076 this.parseError = this.yy.parseError;
2077 }
2078
2079 function popStack( n ) {
2080 stack.length = stack.length - 2 * n;
2081 vstack.length = vstack.length - n;
2082 lstack.length = lstack.length - n;
2083 }
2084
2085 function lex() {
2086 var token;
2087 token = self.lexer.lex() || 1;
2088 if ( typeof token !== "number" ) {
2089 token = self.symbols_[token] || token;
2090 }
2091 return token;
2092 }
2093
2094 var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
2095 while ( true ) {
2096 state = stack[stack.length - 1];
2097 if ( this.defaultActions[state] ) {
2098 action = this.defaultActions[state];
2099 }
2100 else {
2101 if ( symbol === null || typeof symbol == "undefined" ) {
2102 symbol = lex();
2103 }
2104 action = table[state] && table[state][symbol];
2105 }
2106 if ( typeof action === "undefined" || !action.length || !action[0] ) {
2107 var errStr = "";
2108 if ( !recovering ) {
2109 expected = [];
2110 for ( p in table[state] ) {
2111 if ( this.terminals_[p] && p > 2 ) {
2112 expected.push( "'" + this.terminals_[p] + "'" );
2113 }
2114 }
2115 if ( this.lexer.showPosition ) {
2116 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join( ", " ) + ", got '" + (this.terminals_[symbol] || symbol) + "'";
2117 }
2118 else {
2119 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1 ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
2120 }
2121 this.parseError( errStr, {
2122 text : this.lexer.match,
2123 token : this.terminals_[symbol] || symbol,
2124 line : this.lexer.yylineno,
2125 loc : yyloc,
2126 expected : expected
2127 } );
2128 }
2129 }
2130 if ( action[0] instanceof Array && action.length > 1 ) {
2131 throw new Error( "Parse Error: multiple actions possible at state: " + state + ", token: " + symbol );
2132 }
2133 switch ( action[0] ) {
2134 case 1:
2135 stack.push( symbol );
2136 vstack.push( this.lexer.yytext );
2137 lstack.push( this.lexer.yylloc );
2138 stack.push( action[1] );
2139 symbol = null;
2140 if ( !preErrorSymbol ) {
2141 yyleng = this.lexer.yyleng;
2142 yytext = this.lexer.yytext;
2143 yylineno = this.lexer.yylineno;
2144 yyloc = this.lexer.yylloc;
2145 if ( recovering > 0 ) {
2146 recovering--;
2147 }
2148 }
2149 else {
2150 symbol = preErrorSymbol;
2151 preErrorSymbol = null;
2152 }
2153 break;
2154 case 2:
2155 len = this.productions_[action[1]][1];
2156 yyval.$ = vstack[vstack.length - len];
2157 yyval._$ = {
2158 first_line : lstack[lstack.length - (len || 1)].first_line,
2159 last_line : lstack[lstack.length - 1].last_line,
2160 first_column : lstack[lstack.length - (len || 1)].first_column,
2161 last_column : lstack[lstack.length - 1].last_column
2162 };
2163 if ( ranges ) {
2164 yyval._$.range = [
2165 lstack[lstack.length - (len || 1)].range[0],
2166 lstack[lstack.length - 1].range[1]
2167 ];
2168 }
2169 r = this.performAction.call( yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack );
2170 if ( typeof r !== "undefined" ) {
2171 return r;
2172 }
2173 if ( len ) {
2174 stack = stack.slice( 0, -1 * len * 2 );
2175 vstack = vstack.slice( 0, -1 * len );
2176 lstack = lstack.slice( 0, -1 * len );
2177 }
2178 stack.push( this.productions_[action[1]][0] );
2179 vstack.push( yyval.$ );
2180 lstack.push( yyval._$ );
2181 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
2182 stack.push( newState );
2183 break;
2184 case 3:
2185 return true;
2186 }
2187 }
2188 return true;
2189 }
2190 };
2191 /* Jison generated lexer */
2192 var lexer = (function () {
2193 var lexer = ({
2194 EOF : 1, parseError : function parseError( str, hash ) {
2195 if ( this.yy.parser ) {
2196 this.yy.parser.parseError( str, hash );
2197 }
2198 else {
2199 throw new Error( str );
2200 }
2201 }, setInput : function ( input ) {
2202 this._input = input;
2203 this._more = this._less = this.done = false;
2204 this.yylineno = this.yyleng = 0;
2205 this.yytext = this.matched = this.match = '';
2206 this.conditionStack = ['INITIAL'];
2207 this.yylloc = {first_line : 1, first_column : 0, last_line : 1, last_column : 0};
2208 if ( this.options.ranges ) {
2209 this.yylloc.range = [
2210 0,
2211 0
2212 ];
2213 }
2214 this.offset = 0;
2215 return this;
2216 }, input : function () {
2217 var ch = this._input[0];
2218 this.yytext += ch;
2219 this.yyleng++;
2220 this.offset++;
2221 this.match += ch;
2222 this.matched += ch;
2223 var lines = ch.match( /(?:\r\n?|\n).*/g );
2224 if ( lines ) {
2225 this.yylineno++;
2226 this.yylloc.last_line++;
2227 }
2228 else {
2229 this.yylloc.last_column++;
2230 }
2231 if ( this.options.ranges ) {
2232 this.yylloc.range[1]++;
2233 }
2234
2235 this._input = this._input.slice( 1 );
2236 return ch;
2237 }, unput : function ( ch ) {
2238 var len = ch.length;
2239 var lines = ch.split( /(?:\r\n?|\n)/g );
2240
2241 this._input = ch + this._input;
2242 this.yytext = this.yytext.substr( 0, this.yytext.length - len - 1 );
2243 //this.yyleng -= len;
2244 this.offset -= len;
2245 var oldLines = this.match.split( /(?:\r\n?|\n)/g );
2246 this.match = this.match.substr( 0, this.match.length - 1 );
2247 this.matched = this.matched.substr( 0, this.matched.length - 1 );
2248
2249 if ( lines.length - 1 ) {
2250 this.yylineno -= lines.length - 1;
2251 }
2252 var r = this.yylloc.range;
2253
2254 this.yylloc = {
2255 first_line : this.yylloc.first_line,
2256 last_line : this.yylineno + 1,
2257 first_column : this.yylloc.first_column,
2258 last_column : lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
2259 };
2260
2261 if ( this.options.ranges ) {
2262 this.yylloc.range = [
2263 r[0],
2264 r[0] + this.yyleng - len
2265 ];
2266 }
2267 return this;
2268 }, more : function () {
2269 this._more = true;
2270 return this;
2271 }, less : function ( n ) {
2272 this.unput( this.match.slice( n ) );
2273 }, pastInput : function () {
2274 var past = this.matched.substr( 0, this.matched.length - this.match.length );
2275 return (past.length > 20 ? '...' : '') + past.substr( -20 ).replace( /\n/g, "" );
2276 }, upcomingInput : function () {
2277 var next = this.match;
2278 if ( next.length < 20 ) {
2279 next += this._input.substr( 0, 20 - next.length );
2280 }
2281 return (next.substr( 0, 20 ) + (next.length > 20 ? '...' : '')).replace( /\n/g, "" );
2282 }, showPosition : function () {
2283 var pre = this.pastInput();
2284 var c = new Array( pre.length + 1 ).join( "-" );
2285 return pre + this.upcomingInput() + "\n" + c + "^";
2286 }, next : function () {
2287 if ( this.done ) {
2288 return this.EOF;
2289 }
2290 if ( !this._input ) {
2291 this.done = true;
2292 }
2293
2294 var token, match, tempMatch, index, col, lines;
2295 if ( !this._more ) {
2296 this.yytext = '';
2297 this.match = '';
2298 }
2299 var rules = this._currentRules();
2300 for ( var i = 0; i < rules.length; i++ ) {
2301 tempMatch = this._input.match( this.rules[rules[i]] );
2302 if ( tempMatch && (!match || tempMatch[0].length > match[0].length) ) {
2303 match = tempMatch;
2304 index = i;
2305 if ( !this.options.flex ) {
2306 break;
2307 }
2308 }
2309 }
2310 if ( match ) {
2311 lines = match[0].match( /(?:\r\n?|\n).*/g );
2312 if ( lines ) {
2313 this.yylineno += lines.length;
2314 }
2315 this.yylloc = {
2316 first_line : this.yylloc.last_line,
2317 last_line : this.yylineno + 1,
2318 first_column : this.yylloc.last_column,
2319 last_column : lines ? lines[lines.length - 1].length - lines[lines.length - 1].match( /\r?\n?/ )[0].length : this.yylloc.last_column + match[0].length
2320 };
2321 this.yytext += match[0];
2322 this.match += match[0];
2323 this.matches = match;
2324 this.yyleng = this.yytext.length;
2325 if ( this.options.ranges ) {
2326 this.yylloc.range = [
2327 this.offset,
2328 this.offset += this.yyleng
2329 ];
2330 }
2331 this._more = false;
2332 this._input = this._input.slice( match[0].length );
2333 this.matched += match[0];
2334 token = this.performAction.call( this, this.yy, this, rules[index], this.conditionStack[this.conditionStack.length - 1] );
2335 if ( this.done && this._input ) {
2336 this.done = false;
2337 }
2338 if ( token ) {
2339 return token;
2340 }
2341 else {
2342 return;
2343 }
2344 }
2345 if ( this._input === "" ) {
2346 return this.EOF;
2347 }
2348 else {
2349 return this.parseError( 'Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
2350 text : "",
2351 token : null,
2352 line : this.yylineno
2353 } );
2354 }
2355 }, lex : function lex() {
2356 var r = this.next();
2357 if ( typeof r !== 'undefined' ) {
2358 return r;
2359 }
2360 else {
2361 return this.lex();
2362 }
2363 }, begin : function begin( condition ) {
2364 this.conditionStack.push( condition );
2365 }, popState : function popState() {
2366 return this.conditionStack.pop();
2367 }, _currentRules : function _currentRules() {
2368 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
2369 }, topState : function () {
2370 return this.conditionStack[this.conditionStack.length - 2];
2371 }, pushState : function begin( condition ) {
2372 this.begin( condition );
2373 }
2374 });
2375 lexer.options = {};
2376 lexer.performAction = function anonymous( yy, yy_, $avoiding_name_collisions, YY_START ) {
2377
2378 var YYSTATE = YY_START;
2379 switch ( $avoiding_name_collisions ) {
2380 case 0:
2381 yy_.yytext = "\\";
2382 return 14;
2383 break;
2384 case 1:
2385 if ( yy_.yytext.slice( -1 ) !== "\\" ) {
2386 this.begin( "mu" );
2387 }
2388 if ( yy_.yytext.slice( -1 ) === "\\" ) {
2389 yy_.yytext = yy_.yytext.substr( 0, yy_.yyleng - 1 ), this.begin( "emu" );
2390 }
2391 if ( yy_.yytext ) {
2392 return 14;
2393 }
2394
2395 break;
2396 case 2:
2397 return 14;
2398 break;
2399 case 3:
2400 if ( yy_.yytext.slice( -1 ) !== "\\" ) {
2401 this.popState();
2402 }
2403 if ( yy_.yytext.slice( -1 ) === "\\" ) {
2404 yy_.yytext = yy_.yytext.substr( 0, yy_.yyleng - 1 );
2405 }
2406 return 14;
2407
2408 break;
2409 case 4:
2410 yy_.yytext = yy_.yytext.substr( 0, yy_.yyleng - 4 );
2411 this.popState();
2412 return 15;
2413 break;
2414 case 5:
2415 return 25;
2416 break;
2417 case 6:
2418 return 16;
2419 break;
2420 case 7:
2421 return 20;
2422 break;
2423 case 8:
2424 return 19;
2425 break;
2426 case 9:
2427 return 19;
2428 break;
2429 case 10:
2430 return 23;
2431 break;
2432 case 11:
2433 return 22;
2434 break;
2435 case 12:
2436 this.popState();
2437 this.begin( 'com' );
2438 break;
2439 case 13:
2440 yy_.yytext = yy_.yytext.substr( 3, yy_.yyleng - 5 );
2441 this.popState();
2442 return 15;
2443 break;
2444 case 14:
2445 return 22;
2446 break;
2447 case 15:
2448 return 37;
2449 break;
2450 case 16:
2451 return 36;
2452 break;
2453 case 17:
2454 return 36;
2455 break;
2456 case 18:
2457 return 40;
2458 break;
2459 case 19: /*ignore whitespace*/
2460 break;
2461 case 20:
2462 this.popState();
2463 return 24;
2464 break;
2465 case 21:
2466 this.popState();
2467 return 18;
2468 break;
2469 case 22:
2470 yy_.yytext = yy_.yytext.substr( 1, yy_.yyleng - 2 ).replace( /\\"/g, '"' );
2471 return 31;
2472 break;
2473 case 23:
2474 yy_.yytext = yy_.yytext.substr( 1, yy_.yyleng - 2 ).replace( /\\'/g, "'" );
2475 return 31;
2476 break;
2477 case 24:
2478 return 38;
2479 break;
2480 case 25:
2481 return 33;
2482 break;
2483 case 26:
2484 return 33;
2485 break;
2486 case 27:
2487 return 32;
2488 break;
2489 case 28:
2490 return 36;
2491 break;
2492 case 29:
2493 yy_.yytext = yy_.yytext.substr( 1, yy_.yyleng - 2 );
2494 return 36;
2495 break;
2496 case 30:
2497 return 'INVALID';
2498 break;
2499 case 31:
2500 return 5;
2501 break;
2502 }
2503 };
2504 lexer.rules = [
2505 /^(?:\\\\(?=(\{\{)))/,
2506 /^(?:[^\x00]*?(?=(\{\{)))/,
2507 /^(?:[^\x00]+)/,
2508 /^(?:[^\x00]{2,}?(?=(\{\{|$)))/,
2509 /^(?:[\s\S]*?--\}\})/,
2510 /^(?:\{\{>)/,
2511 /^(?:\{\{#)/,
2512 /^(?:\{\{\/)/,
2513 /^(?:\{\{\^)/,
2514 /^(?:\{\{\s*else\b)/,
2515 /^(?:\{\{\{)/,
2516 /^(?:\{\{&)/,
2517 /^(?:\{\{!--)/,
2518 /^(?:\{\{![\s\S]*?\}\})/,
2519 /^(?:\{\{)/,
2520 /^(?:=)/,
2521 /^(?:\.(?=[}\/ ]))/,
2522 /^(?:\.\.)/,
2523 /^(?:[\/.])/,
2524 /^(?:\s+)/,
2525 /^(?:\}\}\})/,
2526 /^(?:\}\})/,
2527 /^(?:"(\\["]|[^"])*")/,
2528 /^(?:'(\\[']|[^'])*')/,
2529 /^(?:@)/,
2530 /^(?:true(?=[}\s]))/,
2531 /^(?:false(?=[}\s]))/,
2532 /^(?:-?[0-9]+(?=[}\s]))/,
2533 /^(?:[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.]))/,
2534 /^(?:\[[^\]]*\])/,
2535 /^(?:.)/,
2536 /^(?:$)/
2537 ];
2538 lexer.conditions = {
2539 "mu" : {
2540 "rules" : [
2541 5,
2542 6,
2543 7,
2544 8,
2545 9,
2546 10,
2547 11,
2548 12,
2549 13,
2550 14,
2551 15,
2552 16,
2553 17,
2554 18,
2555 19,
2556 20,
2557 21,
2558 22,
2559 23,
2560 24,
2561 25,
2562 26,
2563 27,
2564 28,
2565 29,
2566 30,
2567 31
2568 ], "inclusive" : false
2569 },
2570 "emu" : {"rules" : [3], "inclusive" : false},
2571 "com" : {"rules" : [4], "inclusive" : false},
2572 "INITIAL" : {
2573 "rules" : [
2574 0,
2575 1,
2576 2,
2577 31
2578 ], "inclusive" : true
2579 }
2580 };
2581 return lexer;
2582 })();
2583 parser.lexer = lexer;
2584
2585 function Parser() {
2586 this.yy = {};
2587 }
2588
2589 Parser.prototype = parser;
2590 parser.Parser = Parser;
2591 return new Parser;
2592 })();
2593 ;
2594 // lib/handlebars/compiler/base.js
2595
2596 Handlebars.Parser = handlebars;
2597
2598 Handlebars.parse = function ( input ) {
2599
2600 // Just return if an already-compile AST was passed in.
2601 if ( input.constructor === Handlebars.AST.ProgramNode ) {
2602 return input;
2603 }
2604
2605 Handlebars.Parser.yy = Handlebars.AST;
2606 return Handlebars.Parser.parse( input );
2607 };
2608 ;
2609 // lib/handlebars/compiler/ast.js
2610 Handlebars.AST = {};
2611
2612 Handlebars.AST.ProgramNode = function ( statements, inverse ) {
2613 this.type = "program";
2614 this.statements = statements;
2615 if ( inverse ) {
2616 this.inverse = new Handlebars.AST.ProgramNode( inverse );
2617 }
2618 };
2619
2620 Handlebars.AST.MustacheNode = function ( rawParams, hash, unescaped ) {
2621 this.type = "mustache";
2622 this.escaped = !unescaped;
2623 this.hash = hash;
2624
2625 var id = this.id = rawParams[0];
2626 var params = this.params = rawParams.slice( 1 );
2627
2628 // a mustache is an eligible helper if:
2629 // * its id is simple (a single part, not `this` or `..`)
2630 var eligibleHelper = this.eligibleHelper = id.isSimple;
2631
2632 // a mustache is definitely a helper if:
2633 // * it is an eligible helper, and
2634 // * it has at least one parameter or hash segment
2635 this.isHelper = eligibleHelper && (params.length || hash);
2636
2637 // if a mustache is an eligible helper but not a definite
2638 // helper, it is ambiguous, and will be resolved in a later
2639 // pass or at runtime.
2640 };
2641
2642 Handlebars.AST.PartialNode = function ( partialName, context ) {
2643 this.type = "partial";
2644 this.partialName = partialName;
2645 this.context = context;
2646 };
2647
2648 Handlebars.AST.BlockNode = function ( mustache, program, inverse, close ) {
2649 var verifyMatch = function ( open, close ) {
2650 if ( open.original !== close.original ) {
2651 throw new Handlebars.Exception( open.original + " doesn't match " + close.original );
2652 }
2653 };
2654
2655 verifyMatch( mustache.id, close );
2656 this.type = "block";
2657 this.mustache = mustache;
2658 this.program = program;
2659 this.inverse = inverse;
2660
2661 if ( this.inverse && !this.program ) {
2662 this.isInverse = true;
2663 }
2664 };
2665
2666 Handlebars.AST.ContentNode = function ( string ) {
2667 this.type = "content";
2668 this.string = string;
2669 };
2670
2671 Handlebars.AST.HashNode = function ( pairs ) {
2672 this.type = "hash";
2673 this.pairs = pairs;
2674 };
2675
2676 Handlebars.AST.IdNode = function ( parts ) {
2677 this.type = "ID";
2678
2679 var original = "", dig = [], depth = 0;
2680
2681 for ( var i = 0, l = parts.length; i < l; i++ ) {
2682 var part = parts[i].part;
2683 original += (parts[i].separator || '') + part;
2684
2685 if ( part === ".." || part === "." || part === "this" ) {
2686 if ( dig.length > 0 ) {
2687 throw new Handlebars.Exception( "Invalid path: " + original );
2688 }
2689 else {
2690 if ( part === ".." ) {
2691 depth++;
2692 }
2693 else {
2694 this.isScoped = true;
2695 }
2696 }
2697 }
2698 else {
2699 dig.push( part );
2700 }
2701 }
2702
2703 this.original = original;
2704 this.parts = dig;
2705 this.string = dig.join( '.' );
2706 this.depth = depth;
2707
2708 // an ID is simple if it only has one part, and that part is not
2709 // `..` or `this`.
2710 this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
2711
2712 this.stringModeValue = this.string;
2713 };
2714
2715 Handlebars.AST.PartialNameNode = function ( name ) {
2716 this.type = "PARTIAL_NAME";
2717 this.name = name.original;
2718 };
2719
2720 Handlebars.AST.DataNode = function ( id ) {
2721 this.type = "DATA";
2722 this.id = id;
2723 };
2724
2725 Handlebars.AST.StringNode = function ( string ) {
2726 this.type = "STRING";
2727 this.original = this.string = this.stringModeValue = string;
2728 };
2729
2730 Handlebars.AST.IntegerNode = function ( integer ) {
2731 this.type = "INTEGER";
2732 this.original = this.integer = integer;
2733 this.stringModeValue = Number( integer );
2734 };
2735
2736 Handlebars.AST.BooleanNode = function ( bool ) {
2737 this.type = "BOOLEAN";
2738 this.bool = bool;
2739 this.stringModeValue = bool === "true";
2740 };
2741
2742 Handlebars.AST.CommentNode = function ( comment ) {
2743 this.type = "comment";
2744 this.comment = comment;
2745 };
2746 ;
2747 // lib/handlebars/utils.js
2748
2749 var errorProps = [
2750 'description',
2751 'fileName',
2752 'lineNumber',
2753 'message',
2754 'name',
2755 'number',
2756 'stack'
2757 ];
2758
2759 Handlebars.Exception = function ( message ) {
2760 var tmp = Error.prototype.constructor.apply( this, arguments );
2761
2762 // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
2763 for ( var idx = 0; idx < errorProps.length; idx++ ) {
2764 this[errorProps[idx]] = tmp[errorProps[idx]];
2765 }
2766 };
2767 Handlebars.Exception.prototype = new Error();
2768
2769 // Build out our basic SafeString type
2770 Handlebars.SafeString = function ( string ) {
2771 this.string = string;
2772 };
2773 Handlebars.SafeString.prototype.toString = function () {
2774 return this.string.toString();
2775 };
2776
2777 var escape = {
2778 "&" : "&amp;", "<" : "&lt;", ">" : "&gt;", '"' : "&quot;", "'" : "&#x27;", "`" : "&#x60;"
2779 };
2780
2781 var badChars = /[&<>"'`]/g;
2782 var possible = /[&<>"'`]/;
2783
2784 var escapeChar = function ( chr ) {
2785 return escape[chr] || "&amp;";
2786 };
2787
2788 Handlebars.Utils = {
2789 extend : function ( obj, value ) {
2790 for ( var key in value ) {
2791 if ( value.hasOwnProperty( key ) ) {
2792 obj[key] = value[key];
2793 }
2794 }
2795 },
2796
2797 escapeExpression : function ( string ) {
2798 // don't escape SafeStrings, since they're already safe
2799 if ( string instanceof Handlebars.SafeString ) {
2800 return string.toString();
2801 }
2802 else {
2803 if ( string == null || string === false ) {
2804 return "";
2805 }
2806 }
2807
2808 // Force a string conversion as this will be done by the append regardless and
2809 // the regex test will do this transparently behind the scenes, causing issues if
2810 // an object's to string has escaped characters in it.
2811 string = string.toString();
2812
2813 if ( !possible.test( string ) ) {
2814 return string;
2815 }
2816 return string.replace( badChars, escapeChar );
2817 },
2818
2819 isEmpty : function ( value ) {
2820 if ( !value && value !== 0 ) {
2821 return true;
2822 }
2823 else {
2824 if ( toString.call( value ) === "[object Array]" && value.length === 0 ) {
2825 return true;
2826 }
2827 else {
2828 return false;
2829 }
2830 }
2831 }
2832 };
2833 ;
2834 // lib/handlebars/compiler/compiler.js
2835
2836 /*jshint eqnull:true*/
2837 var Compiler = Handlebars.Compiler = function () {
2838 };
2839 var JavaScriptCompiler = Handlebars.JavaScriptCompiler = function () {
2840 };
2841
2842 // the foundHelper register will disambiguate helper lookup from finding a
2843 // function in a context. This is necessary for mustache compatibility, which
2844 // requires that context functions in blocks are evaluated by blockHelperMissing,
2845 // and then proceed as if the resulting value was provided to blockHelperMissing.
2846
2847 Compiler.prototype = {
2848 compiler : Compiler,
2849
2850 disassemble : function () {
2851 var opcodes = this.opcodes, opcode, out = [], params, param;
2852
2853 for ( var i = 0, l = opcodes.length; i < l; i++ ) {
2854 opcode = opcodes[i];
2855
2856 if ( opcode.opcode === 'DECLARE' ) {
2857 out.push( "DECLARE " + opcode.name + "=" + opcode.value );
2858 }
2859 else {
2860 params = [];
2861 for ( var j = 0; j < opcode.args.length; j++ ) {
2862 param = opcode.args[j];
2863 if ( typeof param === "string" ) {
2864 param = "\"" + param.replace( "\n", "\\n" ) + "\"";
2865 }
2866 params.push( param );
2867 }
2868 out.push( opcode.opcode + " " + params.join( " " ) );
2869 }
2870 }
2871
2872 return out.join( "\n" );
2873 }, equals : function ( other ) {
2874 var len = this.opcodes.length;
2875 if ( other.opcodes.length !== len ) {
2876 return false;
2877 }
2878
2879 for ( var i = 0; i < len; i++ ) {
2880 var opcode = this.opcodes[i], otherOpcode = other.opcodes[i];
2881 if ( opcode.opcode !== otherOpcode.opcode || opcode.args.length !== otherOpcode.args.length ) {
2882 return false;
2883 }
2884 for ( var j = 0; j < opcode.args.length; j++ ) {
2885 if ( opcode.args[j] !== otherOpcode.args[j] ) {
2886 return false;
2887 }
2888 }
2889 }
2890
2891 len = this.children.length;
2892 if ( other.children.length !== len ) {
2893 return false;
2894 }
2895 for ( i = 0; i < len; i++ ) {
2896 if ( !this.children[i].equals( other.children[i] ) ) {
2897 return false;
2898 }
2899 }
2900
2901 return true;
2902 },
2903
2904 guid : 0,
2905
2906 compile : function ( program, options ) {
2907 this.children = [];
2908 this.depths = {list : []};
2909 this.options = options;
2910
2911 // These changes will propagate to the other compiler components
2912 var knownHelpers = this.options.knownHelpers;
2913 this.options.knownHelpers = {
2914 'helperMissing' : true,
2915 'blockHelperMissing' : true,
2916 'each' : true,
2917 'if' : true,
2918 'unless' : true,
2919 'with' : true,
2920 'log' : true
2921 };
2922 if ( knownHelpers ) {
2923 for ( var name in knownHelpers ) {
2924 this.options.knownHelpers[name] = knownHelpers[name];
2925 }
2926 }
2927
2928 return this.program( program );
2929 },
2930
2931 accept : function ( node ) {
2932 return this[node.type]( node );
2933 },
2934
2935 program : function ( program ) {
2936 var statements = program.statements, statement;
2937 this.opcodes = [];
2938
2939 for ( var i = 0, l = statements.length; i < l; i++ ) {
2940 statement = statements[i];
2941 this[statement.type]( statement );
2942 }
2943 this.isSimple = l === 1;
2944
2945 this.depths.list = this.depths.list.sort( function ( a, b ) {
2946 return a - b;
2947 } );
2948
2949 return this;
2950 },
2951
2952 compileProgram : function ( program ) {
2953 var result = new this.compiler().compile( program, this.options );
2954 var guid = this.guid++, depth;
2955
2956 this.usePartial = this.usePartial || result.usePartial;
2957
2958 this.children[guid] = result;
2959
2960 for ( var i = 0, l = result.depths.list.length; i < l; i++ ) {
2961 depth = result.depths.list[i];
2962
2963 if ( depth < 2 ) {
2964 continue;
2965 }
2966 else {
2967 this.addDepth( depth - 1 );
2968 }
2969 }
2970
2971 return guid;
2972 },
2973
2974 block : function ( block ) {
2975 var mustache = block.mustache, program = block.program, inverse = block.inverse;
2976
2977 if ( program ) {
2978 program = this.compileProgram( program );
2979 }
2980
2981 if ( inverse ) {
2982 inverse = this.compileProgram( inverse );
2983 }
2984
2985 var type = this.classifyMustache( mustache );
2986
2987 if ( type === "helper" ) {
2988 this.helperMustache( mustache, program, inverse );
2989 }
2990 else {
2991 if ( type === "simple" ) {
2992 this.simpleMustache( mustache );
2993
2994 // now that the simple mustache is resolved, we need to
2995 // evaluate it by executing `blockHelperMissing`
2996 this.opcode( 'pushProgram', program );
2997 this.opcode( 'pushProgram', inverse );
2998 this.opcode( 'emptyHash' );
2999 this.opcode( 'blockValue' );
3000 }
3001 else {
3002 this.ambiguousMustache( mustache, program, inverse );
3003
3004 // now that the simple mustache is resolved, we need to
3005 // evaluate it by executing `blockHelperMissing`
3006 this.opcode( 'pushProgram', program );
3007 this.opcode( 'pushProgram', inverse );
3008 this.opcode( 'emptyHash' );
3009 this.opcode( 'ambiguousBlockValue' );
3010 }
3011 }
3012
3013 this.opcode( 'append' );
3014 },
3015
3016 hash : function ( hash ) {
3017 var pairs = hash.pairs, pair, val;
3018
3019 this.opcode( 'pushHash' );
3020
3021 for ( var i = 0, l = pairs.length; i < l; i++ ) {
3022 pair = pairs[i];
3023 val = pair[1];
3024
3025 if ( this.options.stringParams ) {
3026 if ( val.depth ) {
3027 this.addDepth( val.depth );
3028 }
3029 this.opcode( 'getContext', val.depth || 0 );
3030 this.opcode( 'pushStringParam', val.stringModeValue, val.type );
3031 }
3032 else {
3033 this.accept( val );
3034 }
3035
3036 this.opcode( 'assignToHash', pair[0] );
3037 }
3038 this.opcode( 'popHash' );
3039 },
3040
3041 partial : function ( partial ) {
3042 var partialName = partial.partialName;
3043 this.usePartial = true;
3044
3045 if ( partial.context ) {
3046 this.ID( partial.context );
3047 }
3048 else {
3049 this.opcode( 'push', 'depth0' );
3050 }
3051
3052 this.opcode( 'invokePartial', partialName.name );
3053 this.opcode( 'append' );
3054 },
3055
3056 content : function ( content ) {
3057 this.opcode( 'appendContent', content.string );
3058 },
3059
3060 mustache : function ( mustache ) {
3061 var options = this.options;
3062 var type = this.classifyMustache( mustache );
3063
3064 if ( type === "simple" ) {
3065 this.simpleMustache( mustache );
3066 }
3067 else {
3068 if ( type === "helper" ) {
3069 this.helperMustache( mustache );
3070 }
3071 else {
3072 this.ambiguousMustache( mustache );
3073 }
3074 }
3075
3076 if ( mustache.escaped && !options.noEscape ) {
3077 this.opcode( 'appendEscaped' );
3078 }
3079 else {
3080 this.opcode( 'append' );
3081 }
3082 },
3083
3084 ambiguousMustache : function ( mustache, program, inverse ) {
3085 var id = mustache.id, name = id.parts[0], isBlock = program != null || inverse != null;
3086
3087 this.opcode( 'getContext', id.depth );
3088
3089 this.opcode( 'pushProgram', program );
3090 this.opcode( 'pushProgram', inverse );
3091
3092 this.opcode( 'invokeAmbiguous', name, isBlock );
3093 },
3094
3095 simpleMustache : function ( mustache ) {
3096 var id = mustache.id;
3097
3098 if ( id.type === 'DATA' ) {
3099 this.DATA( id );
3100 }
3101 else {
3102 if ( id.parts.length ) {
3103 this.ID( id );
3104 }
3105 else {
3106 // Simplified ID for `this`
3107 this.addDepth( id.depth );
3108 this.opcode( 'getContext', id.depth );
3109 this.opcode( 'pushContext' );
3110 }
3111 }
3112
3113 this.opcode( 'resolvePossibleLambda' );
3114 },
3115
3116 helperMustache : function ( mustache, program, inverse ) {
3117 var params = this.setupFullMustacheParams( mustache, program, inverse ), name = mustache.id.parts[0];
3118
3119 if ( this.options.knownHelpers[name] ) {
3120 this.opcode( 'invokeKnownHelper', params.length, name );
3121 }
3122 else {
3123 if ( this.options.knownHelpersOnly ) {
3124 throw new Error( "You specified knownHelpersOnly, but used the unknown helper " + name );
3125 }
3126 else {
3127 this.opcode( 'invokeHelper', params.length, name );
3128 }
3129 }
3130 },
3131
3132 ID : function ( id ) {
3133 this.addDepth( id.depth );
3134 this.opcode( 'getContext', id.depth );
3135
3136 var name = id.parts[0];
3137 if ( !name ) {
3138 this.opcode( 'pushContext' );
3139 }
3140 else {
3141 this.opcode( 'lookupOnContext', id.parts[0] );
3142 }
3143
3144 for ( var i = 1, l = id.parts.length; i < l; i++ ) {
3145 this.opcode( 'lookup', id.parts[i] );
3146 }
3147 },
3148
3149 DATA : function ( data ) {
3150 this.options.data = true;
3151 if ( data.id.isScoped || data.id.depth ) {
3152 throw new Handlebars.Exception( 'Scoped data references are not supported: ' + data.original );
3153 }
3154
3155 this.opcode( 'lookupData' );
3156 var parts = data.id.parts;
3157 for ( var i = 0, l = parts.length; i < l; i++ ) {
3158 this.opcode( 'lookup', parts[i] );
3159 }
3160 },
3161
3162 STRING : function ( string ) {
3163 this.opcode( 'pushString', string.string );
3164 },
3165
3166 INTEGER : function ( integer ) {
3167 this.opcode( 'pushLiteral', integer.integer );
3168 },
3169
3170 BOOLEAN : function ( bool ) {
3171 this.opcode( 'pushLiteral', bool.bool );
3172 },
3173
3174 comment : function () {
3175 },
3176
3177 // HELPERS
3178 opcode : function ( name ) {
3179 this.opcodes.push( {opcode : name, args : [].slice.call( arguments, 1 )} );
3180 },
3181
3182 declare : function ( name, value ) {
3183 this.opcodes.push( {opcode : 'DECLARE', name : name, value : value} );
3184 },
3185
3186 addDepth : function ( depth ) {
3187 if ( isNaN( depth ) ) {
3188 throw new Error( "EWOT" );
3189 }
3190 if ( depth === 0 ) {
3191 return;
3192 }
3193
3194 if ( !this.depths[depth] ) {
3195 this.depths[depth] = true;
3196 this.depths.list.push( depth );
3197 }
3198 },
3199
3200 classifyMustache : function ( mustache ) {
3201 var isHelper = mustache.isHelper;
3202 var isEligible = mustache.eligibleHelper;
3203 var options = this.options;
3204
3205 // if ambiguous, we can possibly resolve the ambiguity now
3206 if ( isEligible && !isHelper ) {
3207 var name = mustache.id.parts[0];
3208
3209 if ( options.knownHelpers[name] ) {
3210 isHelper = true;
3211 }
3212 else {
3213 if ( options.knownHelpersOnly ) {
3214 isEligible = false;
3215 }
3216 }
3217 }
3218
3219 if ( isHelper ) {
3220 return "helper";
3221 }
3222 else {
3223 if ( isEligible ) {
3224 return "ambiguous";
3225 }
3226 else {
3227 return "simple";
3228 }
3229 }
3230 },
3231
3232 pushParams : function ( params ) {
3233 var i = params.length, param;
3234
3235 while ( i-- ) {
3236 param = params[i];
3237
3238 if ( this.options.stringParams ) {
3239 if ( param.depth ) {
3240 this.addDepth( param.depth );
3241 }
3242
3243 this.opcode( 'getContext', param.depth || 0 );
3244 this.opcode( 'pushStringParam', param.stringModeValue, param.type );
3245 }
3246 else {
3247 this[param.type]( param );
3248 }
3249 }
3250 },
3251
3252 setupMustacheParams : function ( mustache ) {
3253 var params = mustache.params;
3254 this.pushParams( params );
3255
3256 if ( mustache.hash ) {
3257 this.hash( mustache.hash );
3258 }
3259 else {
3260 this.opcode( 'emptyHash' );
3261 }
3262
3263 return params;
3264 },
3265
3266 // this will replace setupMustacheParams when we're done
3267 setupFullMustacheParams : function ( mustache, program, inverse ) {
3268 var params = mustache.params;
3269 this.pushParams( params );
3270
3271 this.opcode( 'pushProgram', program );
3272 this.opcode( 'pushProgram', inverse );
3273
3274 if ( mustache.hash ) {
3275 this.hash( mustache.hash );
3276 }
3277 else {
3278 this.opcode( 'emptyHash' );
3279 }
3280
3281 return params;
3282 }
3283 };
3284
3285 var Literal = function ( value ) {
3286 this.value = value;
3287 };
3288
3289 JavaScriptCompiler.prototype = {
3290 // PUBLIC API: You can override these methods in a subclass to provide
3291 // alternative compiled forms for name lookup and buffering semantics
3292 nameLookup : function ( parent, name /* , type*/ ) {
3293 if ( /^[0-9]+$/.test( name ) ) {
3294 return parent + "[" + name + "]";
3295 }
3296 else {
3297 if ( JavaScriptCompiler.isValidJavaScriptVariableName( name ) ) {
3298 return parent + "." + name;
3299 }
3300 else {
3301 return parent + "['" + name + "']";
3302 }
3303 }
3304 },
3305
3306 appendToBuffer : function ( string ) {
3307 if ( this.environment.isSimple ) {
3308 return "return " + string + ";";
3309 }
3310 else {
3311 return {
3312 appendToBuffer : true, content : string, toString : function () {
3313 return "buffer += " + string + ";";
3314 }
3315 };
3316 }
3317 },
3318
3319 initializeBuffer : function () {
3320 return this.quotedString( "" );
3321 },
3322
3323 namespace : "Handlebars", // END PUBLIC API
3324
3325 compile : function ( environment, options, context, asObject ) {
3326 this.environment = environment;
3327 this.options = options || {};
3328
3329 Handlebars.log( Handlebars.logger.DEBUG, this.environment.disassemble() + "\n\n" );
3330
3331 this.name = this.environment.name;
3332 this.isChild = !!context;
3333 this.context = context || {
3334 programs : [], environments : [], aliases : {}
3335 };
3336
3337 this.preamble();
3338
3339 this.stackSlot = 0;
3340 this.stackVars = [];
3341 this.registers = {list : []};
3342 this.compileStack = [];
3343 this.inlineStack = [];
3344
3345 this.compileChildren( environment, options );
3346
3347 var opcodes = environment.opcodes, opcode;
3348
3349 this.i = 0;
3350
3351 for ( l = opcodes.length; this.i < l; this.i++ ) {
3352 opcode = opcodes[this.i];
3353
3354 if ( opcode.opcode === 'DECLARE' ) {
3355 this[opcode.name] = opcode.value;
3356 }
3357 else {
3358 this[opcode.opcode].apply( this, opcode.args );
3359 }
3360 }
3361
3362 return this.createFunctionContext( asObject );
3363 },
3364
3365 nextOpcode : function () {
3366 var opcodes = this.environment.opcodes;
3367 return opcodes[this.i + 1];
3368 },
3369
3370 eat : function () {
3371 this.i = this.i + 1;
3372 },
3373
3374 preamble : function () {
3375 var out = [];
3376
3377 if ( !this.isChild ) {
3378 var namespace = this.namespace;
3379
3380 var copies = "helpers = this.merge(helpers, " + namespace + ".helpers);";
3381 if ( this.environment.usePartial ) {
3382 copies = copies + " partials = this.merge(partials, " + namespace + ".partials);";
3383 }
3384 if ( this.options.data ) {
3385 copies = copies + " data = data || {};";
3386 }
3387 out.push( copies );
3388 }
3389 else {
3390 out.push( '' );
3391 }
3392
3393 if ( !this.environment.isSimple ) {
3394 out.push( ", buffer = " + this.initializeBuffer() );
3395 }
3396 else {
3397 out.push( "" );
3398 }
3399
3400 // track the last context pushed into place to allow skipping the
3401 // getContext opcode when it would be a noop
3402 this.lastContext = 0;
3403 this.source = out;
3404 },
3405
3406 createFunctionContext : function ( asObject ) {
3407 var locals = this.stackVars.concat( this.registers.list );
3408
3409 if ( locals.length > 0 ) {
3410 this.source[1] = this.source[1] + ", " + locals.join( ", " );
3411 }
3412
3413 // Generate minimizer alias mappings
3414 if ( !this.isChild ) {
3415 for ( var alias in this.context.aliases ) {
3416 if ( this.context.aliases.hasOwnProperty( alias ) ) {
3417 this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
3418 }
3419 }
3420 }
3421
3422 if ( this.source[1] ) {
3423 this.source[1] = "var " + this.source[1].substring( 2 ) + ";";
3424 }
3425
3426 // Merge children
3427 if ( !this.isChild ) {
3428 this.source[1] += '\n' + this.context.programs.join( '\n' ) + '\n';
3429 }
3430
3431 if ( !this.environment.isSimple ) {
3432 this.source.push( "return buffer;" );
3433 }
3434
3435 var params = this.isChild ? [
3436 "depth0",
3437 "data"
3438 ] : [
3439 "Handlebars",
3440 "depth0",
3441 "helpers",
3442 "partials",
3443 "data"
3444 ];
3445
3446 for ( var i = 0, l = this.environment.depths.list.length; i < l; i++ ) {
3447 params.push( "depth" + this.environment.depths.list[i] );
3448 }
3449
3450 // Perform a second pass over the output to merge content when possible
3451 var source = this.mergeSource();
3452
3453 if ( !this.isChild ) {
3454 var revision = Handlebars.COMPILER_REVISION, versions = Handlebars.REVISION_CHANGES[revision];
3455 source = "this.compilerInfo = [" + revision + ",'" + versions + "'];\n" + source;
3456 }
3457
3458 if ( asObject ) {
3459 params.push( source );
3460
3461 return Function.apply( this, params );
3462 }
3463 else {
3464 var functionSource = 'function ' + (this.name || '') + '(' + params.join( ',' ) + ') {\n ' + source + '}';
3465 Handlebars.log( Handlebars.logger.DEBUG, functionSource + "\n\n" );
3466 return functionSource;
3467 }
3468 }, mergeSource : function () {
3469 // WARN: We are not handling the case where buffer is still populated as the source should
3470 // not have buffer append operations as their final action.
3471 var source = '', buffer;
3472 for ( var i = 0, len = this.source.length; i < len; i++ ) {
3473 var line = this.source[i];
3474 if ( line.appendToBuffer ) {
3475 if ( buffer ) {
3476 buffer = buffer + '\n + ' + line.content;
3477 }
3478 else {
3479 buffer = line.content;
3480 }
3481 }
3482 else {
3483 if ( buffer ) {
3484 source += 'buffer += ' + buffer + ';\n ';
3485 buffer = undefined;
3486 }
3487 source += line + '\n ';
3488 }
3489 }
3490 return source;
3491 },
3492
3493 // [blockValue]
3494 //
3495 // On stack, before: hash, inverse, program, value
3496 // On stack, after: return value of blockHelperMissing
3497 //
3498 // The purpose of this opcode is to take a block of the form
3499 // `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and
3500 // replace it on the stack with the result of properly
3501 // invoking blockHelperMissing.
3502 blockValue : function () {
3503 this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
3504
3505 var params = ["depth0"];
3506 this.setupParams( 0, params );
3507
3508 this.replaceStack( function ( current ) {
3509 params.splice( 1, 0, current );
3510 return "blockHelperMissing.call(" + params.join( ", " ) + ")";
3511 } );
3512 },
3513
3514 // [ambiguousBlockValue]
3515 //
3516 // On stack, before: hash, inverse, program, value
3517 // Compiler value, before: lastHelper=value of last found helper, if any
3518 // On stack, after, if no lastHelper: same as [blockValue]
3519 // On stack, after, if lastHelper: value
3520 ambiguousBlockValue : function () {
3521 this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
3522
3523 var params = ["depth0"];
3524 this.setupParams( 0, params );
3525
3526 var current = this.topStack();
3527 params.splice( 1, 0, current );
3528
3529 // Use the options value generated from the invocation
3530 params[params.length - 1] = 'options';
3531
3532 this.source.push( "if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join( ", " ) + "); }" );
3533 },
3534
3535 // [appendContent]
3536 //
3537 // On stack, before: ...
3538 // On stack, after: ...
3539 //
3540 // Appends the string value of `content` to the current buffer
3541 appendContent : function ( content ) {
3542 this.source.push( this.appendToBuffer( this.quotedString( content ) ) );
3543 },
3544
3545 // [append]
3546 //
3547 // On stack, before: value, ...
3548 // On stack, after: ...
3549 //
3550 // Coerces `value` to a String and appends it to the current buffer.
3551 //
3552 // If `value` is truthy, or 0, it is coerced into a string and appended
3553 // Otherwise, the empty string is appended
3554 append : function () {
3555 // Force anything that is inlined onto the stack so we don't have duplication
3556 // when we examine local
3557 this.flushInline();
3558 var local = this.popStack();
3559 this.source.push( "if(" + local + " || " + local + " === 0) { " + this.appendToBuffer( local ) + " }" );
3560 if ( this.environment.isSimple ) {
3561 this.source.push( "else { " + this.appendToBuffer( "''" ) + " }" );
3562 }
3563 },
3564
3565 // [appendEscaped]
3566 //
3567 // On stack, before: value, ...
3568 // On stack, after: ...
3569 //
3570 // Escape `value` and append it to the buffer
3571 appendEscaped : function () {
3572 this.context.aliases.escapeExpression = 'this.escapeExpression';
3573
3574 this.source.push( this.appendToBuffer( "escapeExpression(" + this.popStack() + ")" ) );
3575 },
3576
3577 // [getContext]
3578 //
3579 // On stack, before: ...
3580 // On stack, after: ...
3581 // Compiler value, after: lastContext=depth
3582 //
3583 // Set the value of the `lastContext` compiler value to the depth
3584 getContext : function ( depth ) {
3585 if ( this.lastContext !== depth ) {
3586 this.lastContext = depth;
3587 }
3588 },
3589
3590 // [lookupOnContext]
3591 //
3592 // On stack, before: ...
3593 // On stack, after: currentContext[name], ...
3594 //
3595 // Looks up the value of `name` on the current context and pushes
3596 // it onto the stack.
3597 lookupOnContext : function ( name ) {
3598 this.push( this.nameLookup( 'depth' + this.lastContext, name, 'context' ) );
3599 },
3600
3601 // [pushContext]
3602 //
3603 // On stack, before: ...
3604 // On stack, after: currentContext, ...
3605 //
3606 // Pushes the value of the current context onto the stack.
3607 pushContext : function () {
3608 this.pushStackLiteral( 'depth' + this.lastContext );
3609 },
3610
3611 // [resolvePossibleLambda]
3612 //
3613 // On stack, before: value, ...
3614 // On stack, after: resolved value, ...
3615 //
3616 // If the `value` is a lambda, replace it on the stack by
3617 // the return value of the lambda
3618 resolvePossibleLambda : function () {
3619 this.context.aliases.functionType = '"function"';
3620
3621 this.replaceStack( function ( current ) {
3622 return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
3623 } );
3624 },
3625
3626 // [lookup]
3627 //
3628 // On stack, before: value, ...
3629 // On stack, after: value[name], ...
3630 //
3631 // Replace the value on the stack with the result of looking
3632 // up `name` on `value`
3633 lookup : function ( name ) {
3634 this.replaceStack( function ( current ) {
3635 return current + " == null || " + current + " === false ? " + current + " : " + this.nameLookup( current, name, 'context' );
3636 } );
3637 },
3638
3639 // [lookupData]
3640 //
3641 // On stack, before: ...
3642 // On stack, after: data[id], ...
3643 //
3644 // Push the result of looking up `id` on the current data
3645 lookupData : function ( id ) {
3646 this.push( 'data' );
3647 },
3648
3649 // [pushStringParam]
3650 //
3651 // On stack, before: ...
3652 // On stack, after: string, currentContext, ...
3653 //
3654 // This opcode is designed for use in string mode, which
3655 // provides the string value of a parameter along with its
3656 // depth rather than resolving it immediately.
3657 pushStringParam : function ( string, type ) {
3658 this.pushStackLiteral( 'depth' + this.lastContext );
3659
3660 this.pushString( type );
3661
3662 if ( typeof string === 'string' ) {
3663 this.pushString( string );
3664 }
3665 else {
3666 this.pushStackLiteral( string );
3667 }
3668 },
3669
3670 emptyHash : function () {
3671 this.pushStackLiteral( '{}' );
3672
3673 if ( this.options.stringParams ) {
3674 this.register( 'hashTypes', '{}' );
3675 this.register( 'hashContexts', '{}' );
3676 }
3677 }, pushHash : function () {
3678 this.hash = {values : [], types : [], contexts : []};
3679 }, popHash : function () {
3680 var hash = this.hash;
3681 this.hash = undefined;
3682
3683 if ( this.options.stringParams ) {
3684 this.register( 'hashContexts', '{' + hash.contexts.join( ',' ) + '}' );
3685 this.register( 'hashTypes', '{' + hash.types.join( ',' ) + '}' );
3686 }
3687 this.push( '{\n ' + hash.values.join( ',\n ' ) + '\n }' );
3688 },
3689
3690 // [pushString]
3691 //
3692 // On stack, before: ...
3693 // On stack, after: quotedString(string), ...
3694 //
3695 // Push a quoted version of `string` onto the stack
3696 pushString : function ( string ) {
3697 this.pushStackLiteral( this.quotedString( string ) );
3698 },
3699
3700 // [push]
3701 //
3702 // On stack, before: ...
3703 // On stack, after: expr, ...
3704 //
3705 // Push an expression onto the stack
3706 push : function ( expr ) {
3707 this.inlineStack.push( expr );
3708 return expr;
3709 },
3710
3711 // [pushLiteral]
3712 //
3713 // On stack, before: ...
3714 // On stack, after: value, ...
3715 //
3716 // Pushes a value onto the stack. This operation prevents
3717 // the compiler from creating a temporary variable to hold
3718 // it.
3719 pushLiteral : function ( value ) {
3720 this.pushStackLiteral( value );
3721 },
3722
3723 // [pushProgram]
3724 //
3725 // On stack, before: ...
3726 // On stack, after: program(guid), ...
3727 //
3728 // Push a program expression onto the stack. This takes
3729 // a compile-time guid and converts it into a runtime-accessible
3730 // expression.
3731 pushProgram : function ( guid ) {
3732 if ( guid != null ) {
3733 this.pushStackLiteral( this.programExpression( guid ) );
3734 }
3735 else {
3736 this.pushStackLiteral( null );
3737 }
3738 },
3739
3740 // [invokeHelper]
3741 //
3742 // On stack, before: hash, inverse, program, params..., ...
3743 // On stack, after: result of helper invocation
3744 //
3745 // Pops off the helper's parameters, invokes the helper,
3746 // and pushes the helper's return value onto the stack.
3747 //
3748 // If the helper is not found, `helperMissing` is called.
3749 invokeHelper : function ( paramSize, name ) {
3750 this.context.aliases.helperMissing = 'helpers.helperMissing';
3751
3752 var helper = this.lastHelper = this.setupHelper( paramSize, name, true );
3753 var nonHelper = this.nameLookup( 'depth' + this.lastContext, name, 'context' );
3754
3755 this.push( helper.name + ' || ' + nonHelper );
3756 this.replaceStack( function ( name ) {
3757 return name + ' ? ' + name + '.call(' + helper.callParams + ") " + ": helperMissing.call(" + helper.helperMissingParams + ")";
3758 } );
3759 },
3760
3761 // [invokeKnownHelper]
3762 //
3763 // On stack, before: hash, inverse, program, params..., ...
3764 // On stack, after: result of helper invocation
3765 //
3766 // This operation is used when the helper is known to exist,
3767 // so a `helperMissing` fallback is not required.
3768 invokeKnownHelper : function ( paramSize, name ) {
3769 var helper = this.setupHelper( paramSize, name );
3770 this.push( helper.name + ".call(" + helper.callParams + ")" );
3771 },
3772
3773 // [invokeAmbiguous]
3774 //
3775 // On stack, before: hash, inverse, program, params..., ...
3776 // On stack, after: result of disambiguation
3777 //
3778 // This operation is used when an expression like `{{foo}}`
3779 // is provided, but we don't know at compile-time whether it
3780 // is a helper or a path.
3781 //
3782 // This operation emits more code than the other options,
3783 // and can be avoided by passing the `knownHelpers` and
3784 // `knownHelpersOnly` flags at compile-time.
3785 invokeAmbiguous : function ( name, helperCall ) {
3786 this.context.aliases.functionType = '"function"';
3787
3788 this.pushStackLiteral( '{}' ); // Hash value
3789 var helper = this.setupHelper( 0, name, helperCall );
3790
3791 var helperName = this.lastHelper = this.nameLookup( 'helpers', name, 'helper' );
3792
3793 var nonHelper = this.nameLookup( 'depth' + this.lastContext, name, 'context' );
3794 var nextStack = this.nextStack();
3795
3796 this.source.push( 'if (' + nextStack + ' = ' + helperName + ') { ' + nextStack + ' = ' + nextStack + '.call(' + helper.callParams + '); }' );
3797 this.source.push( 'else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }' );
3798 },
3799
3800 // [invokePartial]
3801 //
3802 // On stack, before: context, ...
3803 // On stack after: result of partial invocation
3804 //
3805 // This operation pops off a context, invokes a partial with that context,
3806 // and pushes the result of the invocation back.
3807 invokePartial : function ( name ) {
3808 var params = [
3809 this.nameLookup( 'partials', name, 'partial' ),
3810 "'" + name + "'",
3811 this.popStack(),
3812 "helpers",
3813 "partials"
3814 ];
3815
3816 if ( this.options.data ) {
3817 params.push( "data" );
3818 }
3819
3820 this.context.aliases.self = "this";
3821 this.push( "self.invokePartial(" + params.join( ", " ) + ")" );
3822 },
3823
3824 // [assignToHash]
3825 //
3826 // On stack, before: value, hash, ...
3827 // On stack, after: hash, ...
3828 //
3829 // Pops a value and hash off the stack, assigns `hash[key] = value`
3830 // and pushes the hash back onto the stack.
3831 assignToHash : function ( key ) {
3832 var value = this.popStack(), context, type;
3833
3834 if ( this.options.stringParams ) {
3835 type = this.popStack();
3836 context = this.popStack();
3837 }
3838
3839 var hash = this.hash;
3840 if ( context ) {
3841 hash.contexts.push( "'" + key + "': " + context );
3842 }
3843 if ( type ) {
3844 hash.types.push( "'" + key + "': " + type );
3845 }
3846 hash.values.push( "'" + key + "': (" + value + ")" );
3847 },
3848
3849 // HELPERS
3850
3851 compiler : JavaScriptCompiler,
3852
3853 compileChildren : function ( environment, options ) {
3854 var children = environment.children, child, compiler;
3855
3856 for ( var i = 0, l = children.length; i < l; i++ ) {
3857 child = children[i];
3858 compiler = new this.compiler();
3859
3860 var index = this.matchExistingProgram( child );
3861
3862 if ( index == null ) {
3863 this.context.programs.push( '' ); // Placeholder to prevent name conflicts for nested children
3864 index = this.context.programs.length;
3865 child.index = index;
3866 child.name = 'program' + index;
3867 this.context.programs[index] = compiler.compile( child, options, this.context );
3868 this.context.environments[index] = child;
3869 }
3870 else {
3871 child.index = index;
3872 child.name = 'program' + index;
3873 }
3874 }
3875 }, matchExistingProgram : function ( child ) {
3876 for ( var i = 0, len = this.context.environments.length; i < len; i++ ) {
3877 var environment = this.context.environments[i];
3878 if ( environment && environment.equals( child ) ) {
3879 return i;
3880 }
3881 }
3882 },
3883
3884 programExpression : function ( guid ) {
3885 this.context.aliases.self = "this";
3886
3887 if ( guid == null ) {
3888 return "self.noop";
3889 }
3890
3891 var child = this.environment.children[guid], depths = child.depths.list, depth;
3892
3893 var programParams = [
3894 child.index,
3895 child.name,
3896 "data"
3897 ];
3898
3899 for ( var i = 0, l = depths.length; i < l; i++ ) {
3900 depth = depths[i];
3901
3902 if ( depth === 1 ) {
3903 programParams.push( "depth0" );
3904 }
3905 else {
3906 programParams.push( "depth" + (depth - 1) );
3907 }
3908 }
3909
3910 return (depths.length === 0 ? "self.program(" : "self.programWithDepth(") + programParams.join( ", " ) + ")";
3911 },
3912
3913 register : function ( name, val ) {
3914 this.useRegister( name );
3915 this.source.push( name + " = " + val + ";" );
3916 },
3917
3918 useRegister : function ( name ) {
3919 if ( !this.registers[name] ) {
3920 this.registers[name] = true;
3921 this.registers.list.push( name );
3922 }
3923 },
3924
3925 pushStackLiteral : function ( item ) {
3926 return this.push( new Literal( item ) );
3927 },
3928
3929 pushStack : function ( item ) {
3930 this.flushInline();
3931
3932 var stack = this.incrStack();
3933 if ( item ) {
3934 this.source.push( stack + " = " + item + ";" );
3935 }
3936 this.compileStack.push( stack );
3937 return stack;
3938 },
3939
3940 replaceStack : function ( callback ) {
3941 var prefix = '', inline = this.isInline(), stack;
3942
3943 // If we are currently inline then we want to merge the inline statement into the
3944 // replacement statement via ','
3945 if ( inline ) {
3946 var top = this.popStack( true );
3947
3948 if ( top instanceof Literal ) {
3949 // Literals do not need to be inlined
3950 stack = top.value;
3951 }
3952 else {
3953 // Get or create the current stack name for use by the inline
3954 var name = this.stackSlot ? this.topStackName() : this.incrStack();
3955
3956 prefix = '(' + this.push( name ) + ' = ' + top + '),';
3957 stack = this.topStack();
3958 }
3959 }
3960 else {
3961 stack = this.topStack();
3962 }
3963
3964 var item = callback.call( this, stack );
3965
3966 if ( inline ) {
3967 if ( this.inlineStack.length || this.compileStack.length ) {
3968 this.popStack();
3969 }
3970 this.push( '(' + prefix + item + ')' );
3971 }
3972 else {
3973 // Prevent modification of the context depth variable. Through replaceStack
3974 if ( !/^stack/.test( stack ) ) {
3975 stack = this.nextStack();
3976 }
3977
3978 this.source.push( stack + " = (" + prefix + item + ");" );
3979 }
3980 return stack;
3981 },
3982
3983 nextStack : function () {
3984 return this.pushStack();
3985 },
3986
3987 incrStack : function () {
3988 this.stackSlot++;
3989 if ( this.stackSlot > this.stackVars.length ) {
3990 this.stackVars.push( "stack" + this.stackSlot );
3991 }
3992 return this.topStackName();
3993 }, topStackName : function () {
3994 return "stack" + this.stackSlot;
3995 }, flushInline : function () {
3996 var inlineStack = this.inlineStack;
3997 if ( inlineStack.length ) {
3998 this.inlineStack = [];
3999 for ( var i = 0, len = inlineStack.length; i < len; i++ ) {
4000 var entry = inlineStack[i];
4001 if ( entry instanceof Literal ) {
4002 this.compileStack.push( entry );
4003 }
4004 else {
4005 this.pushStack( entry );
4006 }
4007 }
4008 }
4009 }, isInline : function () {
4010 return this.inlineStack.length;
4011 },
4012
4013 popStack : function ( wrapped ) {
4014 var inline = this.isInline(), item = (inline ? this.inlineStack : this.compileStack).pop();
4015
4016 if ( !wrapped && (item instanceof Literal) ) {
4017 return item.value;
4018 }
4019 else {
4020 if ( !inline ) {
4021 this.stackSlot--;
4022 }
4023 return item;
4024 }
4025 },
4026
4027 topStack : function ( wrapped ) {
4028 var stack = (this.isInline() ? this.inlineStack : this.compileStack), item = stack[stack.length - 1];
4029
4030 if ( !wrapped && (item instanceof Literal) ) {
4031 return item.value;
4032 }
4033 else {
4034 return item;
4035 }
4036 },
4037
4038 quotedString : function ( str ) {
4039 return '"' + str
4040 .replace( /\\/g, '\\\\' )
4041 .replace( /"/g, '\\"' )
4042 .replace( /\n/g, '\\n' )
4043 .replace( /\r/g, '\\r' )
4044 .replace( /\u2028/g, '\\u2028' ) // Per Ecma-262 7.3 + 7.8.4
4045 .replace( /\u2029/g, '\\u2029' ) + '"';
4046 },
4047
4048 setupHelper : function ( paramSize, name, missingParams ) {
4049 var params = [];
4050 this.setupParams( paramSize, params, missingParams );
4051 var foundHelper = this.nameLookup( 'helpers', name, 'helper' );
4052
4053 return {
4054 params : params,
4055 name : foundHelper,
4056 callParams : ["depth0"].concat( params ).join( ", " ),
4057 helperMissingParams : missingParams && [
4058 "depth0",
4059 this.quotedString( name )
4060 ].concat( params ).join( ", " )
4061 };
4062 },
4063
4064 // the params and contexts arguments are passed in arrays
4065 // to fill in
4066 setupParams : function ( paramSize, params, useRegister ) {
4067 var options = [], contexts = [], types = [], param, inverse, program;
4068
4069 options.push( "hash:" + this.popStack() );
4070
4071 inverse = this.popStack();
4072 program = this.popStack();
4073
4074 // Avoid setting fn and inverse if neither are set. This allows
4075 // helpers to do a check for `if (options.fn)`
4076 if ( program || inverse ) {
4077 if ( !program ) {
4078 this.context.aliases.self = "this";
4079 program = "self.noop";
4080 }
4081
4082 if ( !inverse ) {
4083 this.context.aliases.self = "this";
4084 inverse = "self.noop";
4085 }
4086
4087 options.push( "inverse:" + inverse );
4088 options.push( "fn:" + program );
4089 }
4090
4091 for ( var i = 0; i < paramSize; i++ ) {
4092 param = this.popStack();
4093 params.push( param );
4094
4095 if ( this.options.stringParams ) {
4096 types.push( this.popStack() );
4097 contexts.push( this.popStack() );
4098 }
4099 }
4100
4101 if ( this.options.stringParams ) {
4102 options.push( "contexts:[" + contexts.join( "," ) + "]" );
4103 options.push( "types:[" + types.join( "," ) + "]" );
4104 options.push( "hashContexts:hashContexts" );
4105 options.push( "hashTypes:hashTypes" );
4106 }
4107
4108 if ( this.options.data ) {
4109 options.push( "data:data" );
4110 }
4111
4112 options = "{" + options.join( "," ) + "}";
4113 if ( useRegister ) {
4114 this.register( 'options', options );
4115 params.push( 'options' );
4116 }
4117 else {
4118 params.push( options );
4119 }
4120 return params.join( ", " );
4121 }
4122 };
4123
4124 var reservedWords = (
4125 "break else new var" + " case finally return void" + " catch for switch while" + " continue function this with" + " default if throw" + " delete in try" + " do instanceof typeof" + " abstract enum int short" + " boolean export interface static" + " byte extends long super" + " char final native synchronized" + " class float package throws" + " const goto private transient" + " debugger implements protected volatile" + " double import public let yield"
4126 ).split( " " );
4127
4128 var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
4129
4130 for ( var i = 0, l = reservedWords.length; i < l; i++ ) {
4131 compilerWords[reservedWords[i]] = true;
4132 }
4133
4134 JavaScriptCompiler.isValidJavaScriptVariableName = function ( name ) {
4135 if ( !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test( name ) ) {
4136 return true;
4137 }
4138 return false;
4139 };
4140
4141 Handlebars.precompile = function ( input, options ) {
4142 if ( input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode) ) {
4143 throw new Handlebars.Exception( "You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input );
4144 }
4145
4146 options = options || {};
4147 if ( !('data' in options) ) {
4148 options.data = true;
4149 }
4150 var ast = Handlebars.parse( input );
4151 var environment = new Compiler().compile( ast, options );
4152 return new JavaScriptCompiler().compile( environment, options );
4153 };
4154
4155 Handlebars.compile = function ( input, options ) {
4156 if ( input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode) ) {
4157 throw new Handlebars.Exception( "You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input );
4158 }
4159
4160 options = options || {};
4161 if ( !('data' in options) ) {
4162 options.data = true;
4163 }
4164 var compiled;
4165
4166 function compile() {
4167 var ast = Handlebars.parse( input );
4168 var environment = new Compiler().compile( ast, options );
4169 var templateSpec = new JavaScriptCompiler().compile( environment, options, undefined, true );
4170 return Handlebars.template( templateSpec );
4171 }
4172
4173 // Template is only compiled on first use and cached after that point.
4174 return function ( context, options ) {
4175 if ( !compiled ) {
4176 compiled = compile();
4177 }
4178 return compiled.call( this, context, options );
4179 };
4180 };
4181
4182 ;
4183 // lib/handlebars/runtime.js
4184
4185 Handlebars.VM = {
4186 template : function ( templateSpec ) {
4187 // Just add water
4188 var container = {
4189 escapeExpression : Handlebars.Utils.escapeExpression,
4190 invokePartial : Handlebars.VM.invokePartial,
4191 programs : [],
4192 program : function ( i, fn, data ) {
4193 var programWrapper = this.programs[i];
4194 if ( data ) {
4195 programWrapper = Handlebars.VM.program( i, fn, data );
4196 }
4197 else {
4198 if ( !programWrapper ) {
4199 programWrapper = this.programs[i] = Handlebars.VM.program( i, fn );
4200 }
4201 }
4202 return programWrapper;
4203 },
4204 merge : function ( param, common ) {
4205 var ret = param || common;
4206
4207 if ( param && common ) {
4208 ret = {};
4209 Handlebars.Utils.extend( ret, common );
4210 Handlebars.Utils.extend( ret, param );
4211 }
4212 return ret;
4213 },
4214 programWithDepth : Handlebars.VM.programWithDepth,
4215 noop : Handlebars.VM.noop,
4216 compilerInfo : null
4217 };
4218
4219 return function ( context, options ) {
4220 options = options || {};
4221 var result = templateSpec.call( container, Handlebars, context, options.helpers, options.partials, options.data );
4222
4223 var compilerInfo = container.compilerInfo || [], compilerRevision = compilerInfo[0] || 1,
4224 currentRevision = Handlebars.COMPILER_REVISION;
4225
4226 if ( compilerRevision !== currentRevision ) {
4227 if ( compilerRevision < currentRevision ) {
4228 var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
4229 compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
4230 throw "Template was precompiled with an older version of Handlebars than the current runtime. " + "Please update your precompiler to a newer version (" + runtimeVersions + ") or downgrade your runtime to an older version (" + compilerVersions + ").";
4231 }
4232 else {
4233 // Use the embedded version info since the runtime doesn't know about this revision yet
4234 throw "Template was precompiled with a newer version of Handlebars than the current runtime. " + "Please update your runtime to a newer version (" + compilerInfo[1] + ").";
4235 }
4236 }
4237
4238 return result;
4239 };
4240 },
4241
4242 programWithDepth : function ( i, fn, data /*, $depth */ ) {
4243 var args = Array.prototype.slice.call( arguments, 3 );
4244
4245 var program = function ( context, options ) {
4246 options = options || {};
4247
4248 return fn.apply( this, [
4249 context,
4250 options.data || data
4251 ].concat( args ) );
4252 };
4253 program.program = i;
4254 program.depth = args.length;
4255 return program;
4256 }, program : function ( i, fn, data ) {
4257 var program = function ( context, options ) {
4258 options = options || {};
4259
4260 return fn( context, options.data || data );
4261 };
4262 program.program = i;
4263 program.depth = 0;
4264 return program;
4265 }, noop : function () {
4266 return "";
4267 }, invokePartial : function ( partial, name, context, helpers, partials, data ) {
4268 var options = {helpers : helpers, partials : partials, data : data};
4269
4270 if ( partial === undefined ) {
4271 throw new Handlebars.Exception( "The partial " + name + " could not be found" );
4272 }
4273 else {
4274 if ( partial instanceof Function ) {
4275 return partial( context, options );
4276 }
4277 else {
4278 if ( !Handlebars.compile ) {
4279 throw new Handlebars.Exception( "The partial " + name + " could not be compiled when running in runtime-only mode" );
4280 }
4281 else {
4282 partials[name] = Handlebars.compile( partial, {data : data !== undefined} );
4283 return partials[name]( context, options );
4284 }
4285 }
4286 }
4287 }
4288 };
4289
4290 Handlebars.template = Handlebars.VM.template;
4291 ;
4292 // lib/handlebars/browser-suffix.js
4293 })( Handlebars );
4294 ;
4295