handlebars-source 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of handlebars-source might be problematic. Click here for more details.

Files changed (3) hide show
  1. data/dist/handlebars.js +1232 -1024
  2. data/dist/handlebars.runtime.js +100 -55
  3. metadata +1 -1
@@ -1,11 +1,41 @@
1
- // lib/handlebars/base.js
1
+ /*
2
+
3
+ Copyright (C) 2011 by Yehuda Katz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
2
11
 
3
- /*jshint eqnull:true*/
4
- this.Handlebars = {};
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
5
14
 
6
- (function(Handlebars) {
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
7
22
 
8
- Handlebars.VERSION = "1.0.rc.2";
23
+ */
24
+
25
+ // lib/handlebars/browser-prefix.js
26
+ var Handlebars = {};
27
+
28
+ (function(Handlebars, undefined) {
29
+ ;
30
+ // lib/handlebars/base.js
31
+
32
+ Handlebars.VERSION = "1.0.0-rc.3";
33
+ Handlebars.COMPILER_REVISION = 2;
34
+
35
+ Handlebars.REVISION_CHANGES = {
36
+ 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
37
+ 2: '>= 1.0.0-rc.3'
38
+ };
9
39
 
10
40
  Handlebars.helpers = {};
11
41
  Handlebars.partials = {};
@@ -32,8 +62,6 @@ var toString = Object.prototype.toString, functionType = "[object Function]";
32
62
  Handlebars.registerHelper('blockHelperMissing', function(context, options) {
33
63
  var inverse = options.inverse || function() {}, fn = options.fn;
34
64
 
35
-
36
- var ret = "";
37
65
  var type = toString.call(context);
38
66
 
39
67
  if(type === functionType) { context = context.call(this); }
@@ -124,11 +152,7 @@ Handlebars.registerHelper('if', function(context, options) {
124
152
  });
125
153
 
126
154
  Handlebars.registerHelper('unless', function(context, options) {
127
- var fn = options.fn, inverse = options.inverse;
128
- options.fn = inverse;
129
- options.inverse = fn;
130
-
131
- return Handlebars.helpers['if'].call(this, context, options);
155
+ return Handlebars.helpers['if'].call(this, context, {fn: options.inverse, inverse: options.fn});
132
156
  });
133
157
 
134
158
  Handlebars.registerHelper('with', function(context, options) {
@@ -139,8 +163,6 @@ Handlebars.registerHelper('log', function(context, options) {
139
163
  var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
140
164
  Handlebars.log(level, context);
141
165
  });
142
-
143
- }(this.Handlebars));
144
166
  ;
145
167
  // lib/handlebars/utils.js
146
168
 
@@ -164,48 +186,48 @@ Handlebars.SafeString.prototype.toString = function() {
164
186
  return this.string.toString();
165
187
  };
166
188
 
167
- (function() {
168
- var escape = {
169
- "&": "&amp;",
170
- "<": "&lt;",
171
- ">": "&gt;",
172
- '"': "&quot;",
173
- "'": "&#x27;",
174
- "`": "&#x60;"
175
- };
176
-
177
- var badChars = /[&<>"'`]/g;
178
- var possible = /[&<>"'`]/;
179
-
180
- var escapeChar = function(chr) {
181
- return escape[chr] || "&amp;";
182
- };
183
-
184
- Handlebars.Utils = {
185
- escapeExpression: function(string) {
186
- // don't escape SafeStrings, since they're already safe
187
- if (string instanceof Handlebars.SafeString) {
188
- return string.toString();
189
- } else if (string == null || string === false) {
190
- return "";
191
- }
189
+ var escape = {
190
+ "&": "&amp;",
191
+ "<": "&lt;",
192
+ ">": "&gt;",
193
+ '"': "&quot;",
194
+ "'": "&#x27;",
195
+ "`": "&#x60;"
196
+ };
192
197
 
193
- if(!possible.test(string)) { return string; }
194
- return string.replace(badChars, escapeChar);
195
- },
196
-
197
- isEmpty: function(value) {
198
- if (!value && value !== 0) {
199
- return true;
200
- } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
201
- return true;
202
- } else {
203
- return false;
204
- }
198
+ var badChars = /[&<>"'`]/g;
199
+ var possible = /[&<>"'`]/;
200
+
201
+ var escapeChar = function(chr) {
202
+ return escape[chr] || "&amp;";
203
+ };
204
+
205
+ Handlebars.Utils = {
206
+ escapeExpression: function(string) {
207
+ // don't escape SafeStrings, since they're already safe
208
+ if (string instanceof Handlebars.SafeString) {
209
+ return string.toString();
210
+ } else if (string == null || string === false) {
211
+ return "";
205
212
  }
206
- };
207
- })();;
213
+
214
+ if(!possible.test(string)) { return string; }
215
+ return string.replace(badChars, escapeChar);
216
+ },
217
+
218
+ isEmpty: function(value) {
219
+ if (!value && value !== 0) {
220
+ return true;
221
+ } else if(toString.call(value) === "[object Array]" && value.length === 0) {
222
+ return true;
223
+ } else {
224
+ return false;
225
+ }
226
+ }
227
+ };
228
+ ;
208
229
  // lib/handlebars/runtime.js
230
+
209
231
  Handlebars.VM = {
210
232
  template: function(templateSpec) {
211
233
  // Just add water
@@ -225,12 +247,32 @@ Handlebars.VM = {
225
247
  }
226
248
  },
227
249
  programWithDepth: Handlebars.VM.programWithDepth,
228
- noop: Handlebars.VM.noop
250
+ noop: Handlebars.VM.noop,
251
+ compilerInfo: null
229
252
  };
230
253
 
231
254
  return function(context, options) {
232
255
  options = options || {};
233
- return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
256
+ var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
257
+
258
+ var compilerInfo = container.compilerInfo || [],
259
+ compilerRevision = compilerInfo[0] || 1,
260
+ currentRevision = Handlebars.COMPILER_REVISION;
261
+
262
+ if (compilerRevision !== currentRevision) {
263
+ if (compilerRevision < currentRevision) {
264
+ var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
265
+ compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
266
+ throw "Template was precompiled with an older version of Handlebars than the current runtime. "+
267
+ "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").";
268
+ } else {
269
+ // Use the embedded version info since the runtime doesn't know about this revision yet
270
+ throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+
271
+ "Please update your runtime to a newer version ("+compilerInfo[1]+").";
272
+ }
273
+ }
274
+
275
+ return result;
234
276
  };
235
277
  },
236
278
 
@@ -269,3 +311,6 @@ Handlebars.VM = {
269
311
 
270
312
  Handlebars.template = Handlebars.VM.template;
271
313
  ;
314
+ // lib/handlebars/browser-suffix.js
315
+ })(Handlebars);
316
+ ;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: