logster 0.0.1

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