handlebars-source 1.0.0.rc3 → 1.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handlebars-source might be problematic. Click here for more details.
- data/dist/handlebars.js +104 -65
- data/dist/handlebars.runtime.js +49 -20
- metadata +2 -2
data/dist/handlebars.js
CHANGED
@@ -29,24 +29,38 @@ var Handlebars = {};
|
|
29
29
|
;
|
30
30
|
// lib/handlebars/base.js
|
31
31
|
|
32
|
-
Handlebars.VERSION = "1.0.0-rc.
|
33
|
-
Handlebars.COMPILER_REVISION =
|
32
|
+
Handlebars.VERSION = "1.0.0-rc.4";
|
33
|
+
Handlebars.COMPILER_REVISION = 3;
|
34
34
|
|
35
35
|
Handlebars.REVISION_CHANGES = {
|
36
36
|
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
|
37
|
-
2: '
|
37
|
+
2: '== 1.0.0-rc.3',
|
38
|
+
3: '>= 1.0.0-rc.4'
|
38
39
|
};
|
39
40
|
|
40
41
|
Handlebars.helpers = {};
|
41
42
|
Handlebars.partials = {};
|
42
43
|
|
44
|
+
var toString = Object.prototype.toString,
|
45
|
+
functionType = '[object Function]',
|
46
|
+
objectType = '[object Object]';
|
47
|
+
|
43
48
|
Handlebars.registerHelper = function(name, fn, inverse) {
|
44
|
-
if(
|
45
|
-
|
49
|
+
if (toString.call(name) === objectType) {
|
50
|
+
if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
|
51
|
+
Handlebars.Utils.extend(this.helpers, name);
|
52
|
+
} else {
|
53
|
+
if (inverse) { fn.not = inverse; }
|
54
|
+
this.helpers[name] = fn;
|
55
|
+
}
|
46
56
|
};
|
47
57
|
|
48
58
|
Handlebars.registerPartial = function(name, str) {
|
49
|
-
|
59
|
+
if (toString.call(name) === objectType) {
|
60
|
+
Handlebars.Utils.extend(this.partials, name);
|
61
|
+
} else {
|
62
|
+
this.partials[name] = str;
|
63
|
+
}
|
50
64
|
};
|
51
65
|
|
52
66
|
Handlebars.registerHelper('helperMissing', function(arg) {
|
@@ -57,8 +71,6 @@ Handlebars.registerHelper('helperMissing', function(arg) {
|
|
57
71
|
}
|
58
72
|
});
|
59
73
|
|
60
|
-
var toString = Object.prototype.toString, functionType = "[object Function]";
|
61
|
-
|
62
74
|
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
63
75
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
64
76
|
|
@@ -156,7 +168,7 @@ Handlebars.registerHelper('unless', function(context, options) {
|
|
156
168
|
});
|
157
169
|
|
158
170
|
Handlebars.registerHelper('with', function(context, options) {
|
159
|
-
return options.fn(context);
|
171
|
+
if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
|
160
172
|
});
|
161
173
|
|
162
174
|
Handlebars.registerHelper('log', function(context, options) {
|
@@ -552,87 +564,89 @@ pushState:function begin(condition) {
|
|
552
564
|
lexer.options = {};
|
553
565
|
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
554
566
|
|
555
|
-
var YYSTATE=YY_START
|
567
|
+
var YYSTATE=YY_START;
|
556
568
|
switch($avoiding_name_collisions) {
|
557
|
-
case 0:
|
569
|
+
case 0: yy_.yytext = "\\"; return 14;
|
570
|
+
break;
|
571
|
+
case 1:
|
558
572
|
if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
|
559
573
|
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
|
560
574
|
if(yy_.yytext) return 14;
|
561
575
|
|
562
576
|
break;
|
563
|
-
case
|
577
|
+
case 2: return 14;
|
564
578
|
break;
|
565
|
-
case
|
579
|
+
case 3:
|
566
580
|
if(yy_.yytext.slice(-1) !== "\\") this.popState();
|
567
581
|
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
|
568
582
|
return 14;
|
569
583
|
|
570
584
|
break;
|
571
|
-
case
|
572
|
-
break;
|
573
|
-
case 4: this.begin("par"); return 24;
|
585
|
+
case 4: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
|
574
586
|
break;
|
575
|
-
case 5: return
|
587
|
+
case 5: this.begin("par"); return 24;
|
576
588
|
break;
|
577
|
-
case 6: return
|
589
|
+
case 6: return 16;
|
578
590
|
break;
|
579
|
-
case 7: return
|
591
|
+
case 7: return 20;
|
580
592
|
break;
|
581
593
|
case 8: return 19;
|
582
594
|
break;
|
583
|
-
case 9: return
|
595
|
+
case 9: return 19;
|
584
596
|
break;
|
585
597
|
case 10: return 23;
|
586
598
|
break;
|
587
|
-
case 11:
|
599
|
+
case 11: return 23;
|
588
600
|
break;
|
589
|
-
case 12:
|
601
|
+
case 12: this.popState(); this.begin('com');
|
590
602
|
break;
|
591
|
-
case 13: return
|
603
|
+
case 13: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
|
592
604
|
break;
|
593
|
-
case 14: return
|
605
|
+
case 14: return 22;
|
594
606
|
break;
|
595
|
-
case 15: return
|
607
|
+
case 15: return 36;
|
596
608
|
break;
|
597
609
|
case 16: return 35;
|
598
610
|
break;
|
599
|
-
case 17: return
|
611
|
+
case 17: return 35;
|
600
612
|
break;
|
601
|
-
case 18:
|
613
|
+
case 18: return 39;
|
602
614
|
break;
|
603
|
-
case 19:
|
615
|
+
case 19: /*ignore whitespace*/
|
604
616
|
break;
|
605
617
|
case 20: this.popState(); return 18;
|
606
618
|
break;
|
607
|
-
case 21:
|
619
|
+
case 21: this.popState(); return 18;
|
608
620
|
break;
|
609
|
-
case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\
|
621
|
+
case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 30;
|
610
622
|
break;
|
611
|
-
case 23: yy_.yytext = yy_.yytext.substr(1); return
|
623
|
+
case 23: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 30;
|
612
624
|
break;
|
613
|
-
case 24: return
|
625
|
+
case 24: yy_.yytext = yy_.yytext.substr(1); return 28;
|
614
626
|
break;
|
615
627
|
case 25: return 32;
|
616
628
|
break;
|
617
|
-
case 26: return
|
629
|
+
case 26: return 32;
|
630
|
+
break;
|
631
|
+
case 27: return 31;
|
618
632
|
break;
|
619
|
-
case
|
633
|
+
case 28: return 35;
|
620
634
|
break;
|
621
|
-
case
|
635
|
+
case 29: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 35;
|
622
636
|
break;
|
623
|
-
case
|
637
|
+
case 30: return 'INVALID';
|
624
638
|
break;
|
625
|
-
case
|
639
|
+
case 31: /*ignore whitespace*/
|
626
640
|
break;
|
627
|
-
case
|
641
|
+
case 32: this.popState(); return 37;
|
628
642
|
break;
|
629
|
-
case
|
643
|
+
case 33: return 5;
|
630
644
|
break;
|
631
645
|
}
|
632
646
|
};
|
633
|
-
lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_
|
634
|
-
lexer.conditions = {"mu":{"rules":[
|
635
|
-
return lexer;})()
|
647
|
+
lexer.rules = [/^(?:\\\\(?=(\{\{)))/,/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[}/ ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$:\-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:\s+)/,/^(?:[a-zA-Z0-9_$\-\/]+)/,/^(?:$)/];
|
648
|
+
lexer.conditions = {"mu":{"rules":[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,33],"inclusive":false},"emu":{"rules":[3],"inclusive":false},"com":{"rules":[4],"inclusive":false},"par":{"rules":[31,32],"inclusive":false},"INITIAL":{"rules":[0,1,2,33],"inclusive":true}};
|
649
|
+
return lexer;})();
|
636
650
|
parser.lexer = lexer;
|
637
651
|
function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
|
638
652
|
return new Parser;
|
@@ -815,6 +829,14 @@ var escapeChar = function(chr) {
|
|
815
829
|
};
|
816
830
|
|
817
831
|
Handlebars.Utils = {
|
832
|
+
extend: function(obj, value) {
|
833
|
+
for(var key in value) {
|
834
|
+
if(value.hasOwnProperty(key)) {
|
835
|
+
obj[key] = value[key];
|
836
|
+
}
|
837
|
+
}
|
838
|
+
},
|
839
|
+
|
818
840
|
escapeExpression: function(string) {
|
819
841
|
// don't escape SafeStrings, since they're already safe
|
820
842
|
if (string instanceof Handlebars.SafeString) {
|
@@ -823,6 +845,11 @@ Handlebars.Utils = {
|
|
823
845
|
return "";
|
824
846
|
}
|
825
847
|
|
848
|
+
// Force a string conversion as this will be done by the append regardless and
|
849
|
+
// the regex test will do this transparently behind the scenes, causing issues if
|
850
|
+
// an object's to string has escaped characters in it.
|
851
|
+
string = string.toString();
|
852
|
+
|
826
853
|
if(!possible.test(string)) { return string; }
|
827
854
|
return string.replace(badChars, escapeChar);
|
828
855
|
},
|
@@ -1023,6 +1050,10 @@ Compiler.prototype = {
|
|
1023
1050
|
val = pair[1];
|
1024
1051
|
|
1025
1052
|
if (this.options.stringParams) {
|
1053
|
+
if(val.depth) {
|
1054
|
+
this.addDepth(val.depth);
|
1055
|
+
}
|
1056
|
+
this.opcode('getContext', val.depth || 0);
|
1026
1057
|
this.opcode('pushStringParam', val.stringModeValue, val.type);
|
1027
1058
|
} else {
|
1028
1059
|
this.accept(val);
|
@@ -1106,7 +1137,7 @@ Compiler.prototype = {
|
|
1106
1137
|
|
1107
1138
|
if (this.options.knownHelpers[name]) {
|
1108
1139
|
this.opcode('invokeKnownHelper', params.length, name);
|
1109
|
-
} else if (this.knownHelpersOnly) {
|
1140
|
+
} else if (this.options.knownHelpersOnly) {
|
1110
1141
|
throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name);
|
1111
1142
|
} else {
|
1112
1143
|
this.opcode('invokeHelper', params.length, name);
|
@@ -1607,16 +1638,18 @@ JavaScriptCompiler.prototype = {
|
|
1607
1638
|
|
1608
1639
|
if (this.options.stringParams) {
|
1609
1640
|
this.register('hashTypes', '{}');
|
1641
|
+
this.register('hashContexts', '{}');
|
1610
1642
|
}
|
1611
1643
|
},
|
1612
1644
|
pushHash: function() {
|
1613
|
-
this.hash = {values: [], types: []};
|
1645
|
+
this.hash = {values: [], types: [], contexts: []};
|
1614
1646
|
},
|
1615
1647
|
popHash: function() {
|
1616
1648
|
var hash = this.hash;
|
1617
1649
|
this.hash = undefined;
|
1618
1650
|
|
1619
1651
|
if (this.options.stringParams) {
|
1652
|
+
this.register('hashContexts', '{' + hash.contexts.join(',') + '}');
|
1620
1653
|
this.register('hashTypes', '{' + hash.types.join(',') + '}');
|
1621
1654
|
}
|
1622
1655
|
this.push('{\n ' + hash.values.join(',\n ') + '\n }');
|
@@ -1759,14 +1792,18 @@ JavaScriptCompiler.prototype = {
|
|
1759
1792
|
// and pushes the hash back onto the stack.
|
1760
1793
|
assignToHash: function(key) {
|
1761
1794
|
var value = this.popStack(),
|
1795
|
+
context,
|
1762
1796
|
type;
|
1763
1797
|
|
1764
1798
|
if (this.options.stringParams) {
|
1765
1799
|
type = this.popStack();
|
1766
|
-
this.popStack();
|
1800
|
+
context = this.popStack();
|
1767
1801
|
}
|
1768
1802
|
|
1769
1803
|
var hash = this.hash;
|
1804
|
+
if (context) {
|
1805
|
+
hash.contexts.push("'" + key + "': " + context);
|
1806
|
+
}
|
1770
1807
|
if (type) {
|
1771
1808
|
hash.types.push("'" + key + "': " + type);
|
1772
1809
|
}
|
@@ -1827,12 +1864,7 @@ JavaScriptCompiler.prototype = {
|
|
1827
1864
|
else { programParams.push("depth" + (depth - 1)); }
|
1828
1865
|
}
|
1829
1866
|
|
1830
|
-
|
1831
|
-
return "self.program(" + programParams.join(", ") + ")";
|
1832
|
-
} else {
|
1833
|
-
programParams.shift();
|
1834
|
-
return "self.programWithDepth(" + programParams.join(", ") + ")";
|
1835
|
-
}
|
1867
|
+
return (depths.length === 0 ? "self.program(" : "self.programWithDepth(") + programParams.join(", ") + ")";
|
1836
1868
|
},
|
1837
1869
|
|
1838
1870
|
register: function(name, val) {
|
@@ -1964,7 +1996,9 @@ JavaScriptCompiler.prototype = {
|
|
1964
1996
|
.replace(/\\/g, '\\\\')
|
1965
1997
|
.replace(/"/g, '\\"')
|
1966
1998
|
.replace(/\n/g, '\\n')
|
1967
|
-
.replace(/\r/g, '\\r')
|
1999
|
+
.replace(/\r/g, '\\r')
|
2000
|
+
.replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
|
2001
|
+
.replace(/\u2029/g, '\\u2029') + '"';
|
1968
2002
|
},
|
1969
2003
|
|
1970
2004
|
setupHelper: function(paramSize, name, missingParams) {
|
@@ -2020,6 +2054,7 @@ JavaScriptCompiler.prototype = {
|
|
2020
2054
|
if (this.options.stringParams) {
|
2021
2055
|
options.push("contexts:[" + contexts.join(",") + "]");
|
2022
2056
|
options.push("types:[" + types.join(",") + "]");
|
2057
|
+
options.push("hashContexts:hashContexts");
|
2023
2058
|
options.push("hashTypes:hashTypes");
|
2024
2059
|
}
|
2025
2060
|
|
@@ -2070,7 +2105,7 @@ JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
|
|
2070
2105
|
};
|
2071
2106
|
|
2072
2107
|
Handlebars.precompile = function(input, options) {
|
2073
|
-
if (
|
2108
|
+
if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
|
2074
2109
|
throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
|
2075
2110
|
}
|
2076
2111
|
|
@@ -2084,7 +2119,7 @@ Handlebars.precompile = function(input, options) {
|
|
2084
2119
|
};
|
2085
2120
|
|
2086
2121
|
Handlebars.compile = function(input, options) {
|
2087
|
-
if (
|
2122
|
+
if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
|
2088
2123
|
throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
|
2089
2124
|
}
|
2090
2125
|
|
@@ -2122,13 +2157,11 @@ Handlebars.VM = {
|
|
2122
2157
|
program: function(i, fn, data) {
|
2123
2158
|
var programWrapper = this.programs[i];
|
2124
2159
|
if(data) {
|
2125
|
-
|
2126
|
-
} else if(programWrapper) {
|
2127
|
-
|
2128
|
-
} else {
|
2129
|
-
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
2130
|
-
return programWrapper;
|
2160
|
+
programWrapper = Handlebars.VM.program(i, fn, data);
|
2161
|
+
} else if (!programWrapper) {
|
2162
|
+
programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
|
2131
2163
|
}
|
2164
|
+
return programWrapper;
|
2132
2165
|
},
|
2133
2166
|
programWithDepth: Handlebars.VM.programWithDepth,
|
2134
2167
|
noop: Handlebars.VM.noop,
|
@@ -2160,21 +2193,27 @@ Handlebars.VM = {
|
|
2160
2193
|
};
|
2161
2194
|
},
|
2162
2195
|
|
2163
|
-
programWithDepth: function(fn, data
|
2164
|
-
var args = Array.prototype.slice.call(arguments,
|
2196
|
+
programWithDepth: function(i, fn, data /*, $depth */) {
|
2197
|
+
var args = Array.prototype.slice.call(arguments, 3);
|
2165
2198
|
|
2166
|
-
|
2199
|
+
var program = function(context, options) {
|
2167
2200
|
options = options || {};
|
2168
2201
|
|
2169
2202
|
return fn.apply(this, [context, options.data || data].concat(args));
|
2170
2203
|
};
|
2204
|
+
program.program = i;
|
2205
|
+
program.depth = args.length;
|
2206
|
+
return program;
|
2171
2207
|
},
|
2172
|
-
program: function(fn, data) {
|
2173
|
-
|
2208
|
+
program: function(i, fn, data) {
|
2209
|
+
var program = function(context, options) {
|
2174
2210
|
options = options || {};
|
2175
2211
|
|
2176
2212
|
return fn(context, options.data || data);
|
2177
2213
|
};
|
2214
|
+
program.program = i;
|
2215
|
+
program.depth = 0;
|
2216
|
+
return program;
|
2178
2217
|
},
|
2179
2218
|
noop: function() { return ""; },
|
2180
2219
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
data/dist/handlebars.runtime.js
CHANGED
@@ -29,24 +29,38 @@ var Handlebars = {};
|
|
29
29
|
;
|
30
30
|
// lib/handlebars/base.js
|
31
31
|
|
32
|
-
Handlebars.VERSION = "1.0.0-rc.
|
33
|
-
Handlebars.COMPILER_REVISION =
|
32
|
+
Handlebars.VERSION = "1.0.0-rc.4";
|
33
|
+
Handlebars.COMPILER_REVISION = 3;
|
34
34
|
|
35
35
|
Handlebars.REVISION_CHANGES = {
|
36
36
|
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
|
37
|
-
2: '
|
37
|
+
2: '== 1.0.0-rc.3',
|
38
|
+
3: '>= 1.0.0-rc.4'
|
38
39
|
};
|
39
40
|
|
40
41
|
Handlebars.helpers = {};
|
41
42
|
Handlebars.partials = {};
|
42
43
|
|
44
|
+
var toString = Object.prototype.toString,
|
45
|
+
functionType = '[object Function]',
|
46
|
+
objectType = '[object Object]';
|
47
|
+
|
43
48
|
Handlebars.registerHelper = function(name, fn, inverse) {
|
44
|
-
if(
|
45
|
-
|
49
|
+
if (toString.call(name) === objectType) {
|
50
|
+
if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
|
51
|
+
Handlebars.Utils.extend(this.helpers, name);
|
52
|
+
} else {
|
53
|
+
if (inverse) { fn.not = inverse; }
|
54
|
+
this.helpers[name] = fn;
|
55
|
+
}
|
46
56
|
};
|
47
57
|
|
48
58
|
Handlebars.registerPartial = function(name, str) {
|
49
|
-
|
59
|
+
if (toString.call(name) === objectType) {
|
60
|
+
Handlebars.Utils.extend(this.partials, name);
|
61
|
+
} else {
|
62
|
+
this.partials[name] = str;
|
63
|
+
}
|
50
64
|
};
|
51
65
|
|
52
66
|
Handlebars.registerHelper('helperMissing', function(arg) {
|
@@ -57,8 +71,6 @@ Handlebars.registerHelper('helperMissing', function(arg) {
|
|
57
71
|
}
|
58
72
|
});
|
59
73
|
|
60
|
-
var toString = Object.prototype.toString, functionType = "[object Function]";
|
61
|
-
|
62
74
|
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
63
75
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
64
76
|
|
@@ -156,7 +168,7 @@ Handlebars.registerHelper('unless', function(context, options) {
|
|
156
168
|
});
|
157
169
|
|
158
170
|
Handlebars.registerHelper('with', function(context, options) {
|
159
|
-
return options.fn(context);
|
171
|
+
if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
|
160
172
|
});
|
161
173
|
|
162
174
|
Handlebars.registerHelper('log', function(context, options) {
|
@@ -203,6 +215,14 @@ var escapeChar = function(chr) {
|
|
203
215
|
};
|
204
216
|
|
205
217
|
Handlebars.Utils = {
|
218
|
+
extend: function(obj, value) {
|
219
|
+
for(var key in value) {
|
220
|
+
if(value.hasOwnProperty(key)) {
|
221
|
+
obj[key] = value[key];
|
222
|
+
}
|
223
|
+
}
|
224
|
+
},
|
225
|
+
|
206
226
|
escapeExpression: function(string) {
|
207
227
|
// don't escape SafeStrings, since they're already safe
|
208
228
|
if (string instanceof Handlebars.SafeString) {
|
@@ -211,6 +231,11 @@ Handlebars.Utils = {
|
|
211
231
|
return "";
|
212
232
|
}
|
213
233
|
|
234
|
+
// Force a string conversion as this will be done by the append regardless and
|
235
|
+
// the regex test will do this transparently behind the scenes, causing issues if
|
236
|
+
// an object's to string has escaped characters in it.
|
237
|
+
string = string.toString();
|
238
|
+
|
214
239
|
if(!possible.test(string)) { return string; }
|
215
240
|
return string.replace(badChars, escapeChar);
|
216
241
|
},
|
@@ -238,13 +263,11 @@ Handlebars.VM = {
|
|
238
263
|
program: function(i, fn, data) {
|
239
264
|
var programWrapper = this.programs[i];
|
240
265
|
if(data) {
|
241
|
-
|
242
|
-
} else if(programWrapper) {
|
243
|
-
|
244
|
-
} else {
|
245
|
-
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
246
|
-
return programWrapper;
|
266
|
+
programWrapper = Handlebars.VM.program(i, fn, data);
|
267
|
+
} else if (!programWrapper) {
|
268
|
+
programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
|
247
269
|
}
|
270
|
+
return programWrapper;
|
248
271
|
},
|
249
272
|
programWithDepth: Handlebars.VM.programWithDepth,
|
250
273
|
noop: Handlebars.VM.noop,
|
@@ -276,21 +299,27 @@ Handlebars.VM = {
|
|
276
299
|
};
|
277
300
|
},
|
278
301
|
|
279
|
-
programWithDepth: function(fn, data
|
280
|
-
var args = Array.prototype.slice.call(arguments,
|
302
|
+
programWithDepth: function(i, fn, data /*, $depth */) {
|
303
|
+
var args = Array.prototype.slice.call(arguments, 3);
|
281
304
|
|
282
|
-
|
305
|
+
var program = function(context, options) {
|
283
306
|
options = options || {};
|
284
307
|
|
285
308
|
return fn.apply(this, [context, options.data || data].concat(args));
|
286
309
|
};
|
310
|
+
program.program = i;
|
311
|
+
program.depth = args.length;
|
312
|
+
return program;
|
287
313
|
},
|
288
|
-
program: function(fn, data) {
|
289
|
-
|
314
|
+
program: function(i, fn, data) {
|
315
|
+
var program = function(context, options) {
|
290
316
|
options = options || {};
|
291
317
|
|
292
318
|
return fn(context, options.data || data);
|
293
319
|
};
|
320
|
+
program.program = i;
|
321
|
+
program.depth = 0;
|
322
|
+
return program;
|
294
323
|
},
|
295
324
|
noop: function() { return ""; },
|
296
325
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
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.0.
|
4
|
+
version: 1.0.0.rc4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Handlebars.js source code wrapper for (pre)compilation gems.
|
15
15
|
email:
|