handlebars_assets 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/handlebars_assets/version.rb +1 -1
- data/vendor/assets/javascripts/handlebars.js +107 -167
- data/vendor/assets/javascripts/handlebars.runtime.js +1 -1
- metadata +10 -10
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Using `sprockets` with Sinatra or another framework? **handlebars_assets** works
|
|
12
12
|
|
13
13
|
## handlebars.js
|
14
14
|
|
15
|
-
`handlebars_assets` is packaged with `v1.0.beta.
|
15
|
+
`handlebars_assets` is packaged with `v1.0.beta.6` of `handlebars.js`.
|
16
16
|
|
17
17
|
## Installation with Rails 3.1+
|
18
18
|
|
@@ -138,3 +138,4 @@ Once you've made your great commits
|
|
138
138
|
* Erwan Barrier (@erwanb) : Support for plain sprockets
|
139
139
|
* Brendan Loudermilk (@bloudermilk) : HandlebarsAssets.path
|
140
140
|
* Dan Evans (@danevans) : Rails 2 support
|
141
|
+
* Ben Woosley (@empact) : Update to handlebars.js 1.0.0.beta.6
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// lib/handlebars/base.js
|
2
2
|
var Handlebars = {};
|
3
3
|
|
4
|
-
Handlebars.VERSION = "1.0.beta.
|
4
|
+
Handlebars.VERSION = "1.0.beta.6";
|
5
5
|
|
6
6
|
Handlebars.helpers = {};
|
7
7
|
Handlebars.partials = {};
|
@@ -194,188 +194,103 @@ parseError: function parseError(str, hash) {
|
|
194
194
|
throw new Error(str);
|
195
195
|
},
|
196
196
|
parse: function parse(input) {
|
197
|
-
var self = this,
|
198
|
-
stack = [0],
|
199
|
-
vstack = [null], // semantic value stack
|
200
|
-
lstack = [], // location stack
|
201
|
-
table = this.table,
|
202
|
-
yytext = '',
|
203
|
-
yylineno = 0,
|
204
|
-
yyleng = 0,
|
205
|
-
recovering = 0,
|
206
|
-
TERROR = 2,
|
207
|
-
EOF = 1;
|
208
|
-
|
209
|
-
//this.reductionCount = this.shiftCount = 0;
|
210
|
-
|
197
|
+
var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
211
198
|
this.lexer.setInput(input);
|
212
199
|
this.lexer.yy = this.yy;
|
213
200
|
this.yy.lexer = this.lexer;
|
214
|
-
if (typeof this.lexer.yylloc ==
|
201
|
+
if (typeof this.lexer.yylloc == "undefined")
|
215
202
|
this.lexer.yylloc = {};
|
216
203
|
var yyloc = this.lexer.yylloc;
|
217
204
|
lstack.push(yyloc);
|
218
|
-
|
219
|
-
if (typeof this.yy.parseError === 'function')
|
205
|
+
if (typeof this.yy.parseError === "function")
|
220
206
|
this.parseError = this.yy.parseError;
|
221
|
-
|
222
|
-
|
223
|
-
stack.length = stack.length - 2*n;
|
207
|
+
function popStack(n) {
|
208
|
+
stack.length = stack.length - 2 * n;
|
224
209
|
vstack.length = vstack.length - n;
|
225
210
|
lstack.length = lstack.length - n;
|
226
211
|
}
|
227
|
-
|
228
212
|
function lex() {
|
229
213
|
var token;
|
230
|
-
token = self.lexer.lex() || 1;
|
231
|
-
|
232
|
-
if (typeof token !== 'number') {
|
214
|
+
token = self.lexer.lex() || 1;
|
215
|
+
if (typeof token !== "number") {
|
233
216
|
token = self.symbols_[token] || token;
|
234
217
|
}
|
235
218
|
return token;
|
236
|
-
}
|
237
|
-
|
238
|
-
var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
|
219
|
+
}
|
220
|
+
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
239
221
|
while (true) {
|
240
|
-
|
241
|
-
state = stack[stack.length-1];
|
242
|
-
|
243
|
-
// use default actions if available
|
222
|
+
state = stack[stack.length - 1];
|
244
223
|
if (this.defaultActions[state]) {
|
245
224
|
action = this.defaultActions[state];
|
246
225
|
} else {
|
247
226
|
if (symbol == null)
|
248
227
|
symbol = lex();
|
249
|
-
// read action for current state and first input
|
250
228
|
action = table[state] && table[state][symbol];
|
251
229
|
}
|
252
|
-
|
253
|
-
// handle parse error
|
254
|
-
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
255
|
-
|
230
|
+
if (typeof action === "undefined" || !action.length || !action[0]) {
|
256
231
|
if (!recovering) {
|
257
|
-
// Report error
|
258
232
|
expected = [];
|
259
|
-
for (p in table[state])
|
260
|
-
|
261
|
-
|
262
|
-
|
233
|
+
for (p in table[state])
|
234
|
+
if (this.terminals_[p] && p > 2) {
|
235
|
+
expected.push("'" + this.terminals_[p] + "'");
|
236
|
+
}
|
237
|
+
var errStr = "";
|
263
238
|
if (this.lexer.showPosition) {
|
264
|
-
errStr =
|
239
|
+
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + this.terminals_[symbol] + "'";
|
265
240
|
} else {
|
266
|
-
errStr =
|
267
|
-
(symbol == 1 /*EOF*/ ? "end of input" :
|
268
|
-
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
241
|
+
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
|
269
242
|
}
|
270
|
-
this.parseError(errStr,
|
271
|
-
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
243
|
+
this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
272
244
|
}
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
245
|
+
}
|
246
|
+
if (action[0] instanceof Array && action.length > 1) {
|
247
|
+
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
248
|
+
}
|
249
|
+
switch (action[0]) {
|
250
|
+
case 1:
|
251
|
+
stack.push(symbol);
|
252
|
+
vstack.push(this.lexer.yytext);
|
253
|
+
lstack.push(this.lexer.yylloc);
|
254
|
+
stack.push(action[1]);
|
255
|
+
symbol = null;
|
256
|
+
if (!preErrorSymbol) {
|
281
257
|
yyleng = this.lexer.yyleng;
|
282
258
|
yytext = this.lexer.yytext;
|
283
259
|
yylineno = this.lexer.yylineno;
|
284
260
|
yyloc = this.lexer.yylloc;
|
285
|
-
|
261
|
+
if (recovering > 0)
|
262
|
+
recovering--;
|
263
|
+
} else {
|
264
|
+
symbol = preErrorSymbol;
|
265
|
+
preErrorSymbol = null;
|
286
266
|
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
throw new Error(errStr || 'Parsing halted.');
|
296
|
-
}
|
297
|
-
popStack(1);
|
298
|
-
state = stack[stack.length-1];
|
267
|
+
break;
|
268
|
+
case 2:
|
269
|
+
len = this.productions_[action[1]][1];
|
270
|
+
yyval.$ = vstack[vstack.length - len];
|
271
|
+
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};
|
272
|
+
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
273
|
+
if (typeof r !== "undefined") {
|
274
|
+
return r;
|
299
275
|
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
switch (action[0]) {
|
314
|
-
|
315
|
-
case 1: // shift
|
316
|
-
//this.shiftCount++;
|
317
|
-
|
318
|
-
stack.push(symbol);
|
319
|
-
vstack.push(this.lexer.yytext);
|
320
|
-
lstack.push(this.lexer.yylloc);
|
321
|
-
stack.push(action[1]); // push state
|
322
|
-
symbol = null;
|
323
|
-
if (!preErrorSymbol) { // normal execution/no error
|
324
|
-
yyleng = this.lexer.yyleng;
|
325
|
-
yytext = this.lexer.yytext;
|
326
|
-
yylineno = this.lexer.yylineno;
|
327
|
-
yyloc = this.lexer.yylloc;
|
328
|
-
if (recovering > 0)
|
329
|
-
recovering--;
|
330
|
-
} else { // error just occurred, resume old lookahead f/ before error
|
331
|
-
symbol = preErrorSymbol;
|
332
|
-
preErrorSymbol = null;
|
333
|
-
}
|
334
|
-
break;
|
335
|
-
|
336
|
-
case 2: // reduce
|
337
|
-
//this.reductionCount++;
|
338
|
-
|
339
|
-
len = this.productions_[action[1]][1];
|
340
|
-
|
341
|
-
// perform semantic action
|
342
|
-
yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
|
343
|
-
// default location, uses first token for firsts, last for lasts
|
344
|
-
yyval._$ = {
|
345
|
-
first_line: lstack[lstack.length-(len||1)].first_line,
|
346
|
-
last_line: lstack[lstack.length-1].last_line,
|
347
|
-
first_column: lstack[lstack.length-(len||1)].first_column,
|
348
|
-
last_column: lstack[lstack.length-1].last_column
|
349
|
-
};
|
350
|
-
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
351
|
-
|
352
|
-
if (typeof r !== 'undefined') {
|
353
|
-
return r;
|
354
|
-
}
|
355
|
-
|
356
|
-
// pop off stack
|
357
|
-
if (len) {
|
358
|
-
stack = stack.slice(0,-1*len*2);
|
359
|
-
vstack = vstack.slice(0, -1*len);
|
360
|
-
lstack = lstack.slice(0, -1*len);
|
361
|
-
}
|
362
|
-
|
363
|
-
stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
|
364
|
-
vstack.push(yyval.$);
|
365
|
-
lstack.push(yyval._$);
|
366
|
-
// goto new state = table[STATE][NONTERMINAL]
|
367
|
-
newState = table[stack[stack.length-2]][stack[stack.length-1]];
|
368
|
-
stack.push(newState);
|
369
|
-
break;
|
370
|
-
|
371
|
-
case 3: // accept
|
372
|
-
return true;
|
276
|
+
if (len) {
|
277
|
+
stack = stack.slice(0, -1 * len * 2);
|
278
|
+
vstack = vstack.slice(0, -1 * len);
|
279
|
+
lstack = lstack.slice(0, -1 * len);
|
280
|
+
}
|
281
|
+
stack.push(this.productions_[action[1]][0]);
|
282
|
+
vstack.push(yyval.$);
|
283
|
+
lstack.push(yyval._$);
|
284
|
+
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
285
|
+
stack.push(newState);
|
286
|
+
break;
|
287
|
+
case 3:
|
288
|
+
return true;
|
373
289
|
}
|
374
|
-
|
375
290
|
}
|
376
|
-
|
377
291
|
return true;
|
378
|
-
}
|
292
|
+
}
|
293
|
+
};/* Jison generated lexer */
|
379
294
|
var lexer = (function(){
|
380
295
|
|
381
296
|
var lexer = ({EOF:1,
|
@@ -489,6 +404,12 @@ popState:function popState() {
|
|
489
404
|
},
|
490
405
|
_currentRules:function _currentRules() {
|
491
406
|
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
407
|
+
},
|
408
|
+
topState:function () {
|
409
|
+
return this.conditionStack[this.conditionStack.length-2];
|
410
|
+
},
|
411
|
+
pushState:function begin(condition) {
|
412
|
+
this.begin(condition);
|
492
413
|
}});
|
493
414
|
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
494
415
|
|
@@ -1078,13 +999,13 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1078
999
|
// PUBLIC API: You can override these methods in a subclass to provide
|
1079
1000
|
// alternative compiled forms for name lookup and buffering semantics
|
1080
1001
|
nameLookup: function(parent, name, type) {
|
1081
|
-
|
1002
|
+
if (/^[0-9]+$/.test(name)) {
|
1082
1003
|
return parent + "[" + name + "]";
|
1083
1004
|
} else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1005
|
+
return parent + "." + name;
|
1006
|
+
}
|
1007
|
+
else {
|
1008
|
+
return parent + "['" + name + "']";
|
1088
1009
|
}
|
1089
1010
|
},
|
1090
1011
|
|
@@ -1170,6 +1091,12 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1170
1091
|
preamble: function() {
|
1171
1092
|
var out = [];
|
1172
1093
|
|
1094
|
+
// this register will disambiguate helper lookup from finding a function in
|
1095
|
+
// a context. This is necessary for mustache compatibility, which requires
|
1096
|
+
// that context functions in blocks are evaluated by blockHelperMissing, and
|
1097
|
+
// then proceed as if the resulting value was provided to blockHelperMissing.
|
1098
|
+
this.useRegister('foundHelper');
|
1099
|
+
|
1173
1100
|
if (!this.isChild) {
|
1174
1101
|
var namespace = this.namespace;
|
1175
1102
|
var copies = "helpers = helpers || " + namespace + ".helpers;";
|
@@ -1282,10 +1209,8 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1282
1209
|
} else if (isScoped || this.options.knownHelpersOnly) {
|
1283
1210
|
toPush = topStack + " = " + this.nameLookup('depth' + this.lastContext, name, 'context');
|
1284
1211
|
} else {
|
1285
|
-
|
1286
|
-
|
1287
|
-
+ " || "
|
1288
|
-
+ this.nameLookup('depth' + this.lastContext, name, 'context');
|
1212
|
+
this.register('foundHelper', this.nameLookup('helpers', name, 'helper'));
|
1213
|
+
toPush = topStack + " = foundHelper || " + this.nameLookup('depth' + this.lastContext, name, 'context');
|
1289
1214
|
}
|
1290
1215
|
|
1291
1216
|
toPush += ';';
|
@@ -1298,7 +1223,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1298
1223
|
lookup: function(name) {
|
1299
1224
|
var topStack = this.topStack();
|
1300
1225
|
this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " +
|
1301
|
-
|
1226
|
+
topStack + " : " + this.nameLookup(topStack, name, 'context') + ");");
|
1302
1227
|
},
|
1303
1228
|
|
1304
1229
|
pushStringParam: function(string) {
|
@@ -1380,10 +1305,10 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1380
1305
|
|
1381
1306
|
params.push(stringOptions);
|
1382
1307
|
|
1383
|
-
this.populateCall(params, id, helperId || id, fn);
|
1308
|
+
this.populateCall(params, id, helperId || id, fn, program !== '{}');
|
1384
1309
|
},
|
1385
1310
|
|
1386
|
-
populateCall: function(params, id, helperId, fn) {
|
1311
|
+
populateCall: function(params, id, helperId, fn, program) {
|
1387
1312
|
var paramString = ["depth0"].concat(params).join(", ");
|
1388
1313
|
var helperMissingString = ["depth0"].concat(helperId).concat(params).join(", ");
|
1389
1314
|
|
@@ -1393,7 +1318,8 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1393
1318
|
this.source.push(nextStack + " = " + id + ".call(" + paramString + ");");
|
1394
1319
|
} else {
|
1395
1320
|
this.context.aliases.functionType = '"function"';
|
1396
|
-
|
1321
|
+
var condition = program ? "foundHelper && " : ""
|
1322
|
+
this.source.push("if(" + condition + "typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }");
|
1397
1323
|
}
|
1398
1324
|
fn.call(this, nextStack, helperMissingString, id);
|
1399
1325
|
this.usingKnownHelper = false;
|
@@ -1497,9 +1423,23 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1497
1423
|
}
|
1498
1424
|
};
|
1499
1425
|
|
1500
|
-
var reservedWords = (
|
1501
|
-
|
1502
|
-
|
1426
|
+
var reservedWords = (
|
1427
|
+
"break else new var" +
|
1428
|
+
" case finally return void" +
|
1429
|
+
" catch for switch while" +
|
1430
|
+
" continue function this with" +
|
1431
|
+
" default if throw" +
|
1432
|
+
" delete in try" +
|
1433
|
+
" do instanceof typeof" +
|
1434
|
+
" abstract enum int short" +
|
1435
|
+
" boolean export interface static" +
|
1436
|
+
" byte extends long super" +
|
1437
|
+
" char final native synchronized" +
|
1438
|
+
" class float package throws" +
|
1439
|
+
" const goto private transient" +
|
1440
|
+
" debugger implements protected volatile" +
|
1441
|
+
" double import public let yield"
|
1442
|
+
).split(" ");
|
1503
1443
|
|
1504
1444
|
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
|
1505
1445
|
|
@@ -1507,12 +1447,12 @@ Handlebars.JavaScriptCompiler = function() {};
|
|
1507
1447
|
compilerWords[reservedWords[i]] = true;
|
1508
1448
|
}
|
1509
1449
|
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1450
|
+
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
|
1451
|
+
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
|
1452
|
+
return true;
|
1453
|
+
}
|
1454
|
+
return false;
|
1455
|
+
}
|
1516
1456
|
|
1517
1457
|
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
|
1518
1458
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handlebars_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03
|
12
|
+
date: 2012-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
16
|
-
requirement: &
|
16
|
+
requirement: &70241519231440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.9
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70241519231440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tilt
|
27
|
-
requirement: &
|
27
|
+
requirement: &70241519230900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70241519230900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sprockets
|
38
|
-
requirement: &
|
38
|
+
requirement: &70241519230320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.0.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70241519230320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70241519229840 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70241519229840
|
58
58
|
description: Compile Handlebars templates in the Rails asset pipeline.
|
59
59
|
email:
|
60
60
|
- leshill@gmail.com
|