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