handlebars_assets 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/handlebars_assets/version.rb +1 -1
- data/test/handlebars_assets/tilt_handlebars_test.rb +41 -239
- data/vendor/assets/javascripts/handlebars.js +782 -412
- data/vendor/assets/javascripts/handlebars.runtime.js +31 -13
- metadata +2 -2
@@ -1,7 +1,11 @@
|
|
1
1
|
// lib/handlebars/base.js
|
2
|
-
var Handlebars = {};
|
3
2
|
|
4
|
-
|
3
|
+
/*jshint eqnull:true*/
|
4
|
+
this.Handlebars = {};
|
5
|
+
|
6
|
+
(function(Handlebars) {
|
7
|
+
|
8
|
+
Handlebars.VERSION = "1.0.rc.1";
|
5
9
|
|
6
10
|
Handlebars.helpers = {};
|
7
11
|
Handlebars.partials = {};
|
@@ -40,25 +44,36 @@ Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
|
40
44
|
return inverse(this);
|
41
45
|
} else if(type === "[object Array]") {
|
42
46
|
if(context.length > 0) {
|
43
|
-
|
44
|
-
ret = ret + fn(context[i]);
|
45
|
-
}
|
47
|
+
return Handlebars.helpers.each(context, options);
|
46
48
|
} else {
|
47
|
-
|
49
|
+
return inverse(this);
|
48
50
|
}
|
49
|
-
return ret;
|
50
51
|
} else {
|
51
52
|
return fn(context);
|
52
53
|
}
|
53
54
|
});
|
54
55
|
|
56
|
+
Handlebars.K = function() {};
|
57
|
+
|
58
|
+
Handlebars.createFrame = Object.create || function(object) {
|
59
|
+
Handlebars.K.prototype = object;
|
60
|
+
var obj = new Handlebars.K();
|
61
|
+
Handlebars.K.prototype = null;
|
62
|
+
return obj;
|
63
|
+
};
|
64
|
+
|
55
65
|
Handlebars.registerHelper('each', function(context, options) {
|
56
66
|
var fn = options.fn, inverse = options.inverse;
|
57
|
-
var ret = "";
|
67
|
+
var ret = "", data;
|
68
|
+
|
69
|
+
if (options.data) {
|
70
|
+
data = Handlebars.createFrame(options.data);
|
71
|
+
}
|
58
72
|
|
59
73
|
if(context && context.length > 0) {
|
60
74
|
for(var i=0, j=context.length; i<j; i++) {
|
61
|
-
|
75
|
+
if (data) { data.index = i; }
|
76
|
+
ret = ret + fn(context[i], { data: data });
|
62
77
|
}
|
63
78
|
} else {
|
64
79
|
ret = inverse(this);
|
@@ -92,6 +107,8 @@ Handlebars.registerHelper('with', function(context, options) {
|
|
92
107
|
Handlebars.registerHelper('log', function(context) {
|
93
108
|
Handlebars.log(context);
|
94
109
|
});
|
110
|
+
|
111
|
+
}(this.Handlebars));
|
95
112
|
;
|
96
113
|
// lib/handlebars/utils.js
|
97
114
|
Handlebars.Exception = function(message) {
|
@@ -103,7 +120,7 @@ Handlebars.Exception = function(message) {
|
|
103
120
|
|
104
121
|
this.message = tmp.message;
|
105
122
|
};
|
106
|
-
Handlebars.Exception.prototype = new Error;
|
123
|
+
Handlebars.Exception.prototype = new Error();
|
107
124
|
|
108
125
|
// Build out our basic SafeString type
|
109
126
|
Handlebars.SafeString = function(string) {
|
@@ -115,6 +132,7 @@ Handlebars.SafeString.prototype.toString = function() {
|
|
115
132
|
|
116
133
|
(function() {
|
117
134
|
var escape = {
|
135
|
+
"&": "&",
|
118
136
|
"<": "<",
|
119
137
|
">": ">",
|
120
138
|
'"': """,
|
@@ -122,7 +140,7 @@ Handlebars.SafeString.prototype.toString = function() {
|
|
122
140
|
"`": "`"
|
123
141
|
};
|
124
142
|
|
125
|
-
var badChars =
|
143
|
+
var badChars = /[&<>"'`]/g;
|
126
144
|
var possible = /[&<>"'`]/;
|
127
145
|
|
128
146
|
var escapeChar = function(chr) {
|
@@ -204,7 +222,7 @@ Handlebars.VM = {
|
|
204
222
|
},
|
205
223
|
noop: function() { return ""; },
|
206
224
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
207
|
-
options = { helpers: helpers, partials: partials, data: data };
|
225
|
+
var options = { helpers: helpers, partials: partials, data: data };
|
208
226
|
|
209
227
|
if(partial === undefined) {
|
210
228
|
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
@@ -213,7 +231,7 @@ Handlebars.VM = {
|
|
213
231
|
} else if (!Handlebars.compile) {
|
214
232
|
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
215
233
|
} else {
|
216
|
-
partials[name] = Handlebars.compile(partial);
|
234
|
+
partials[name] = Handlebars.compile(partial, {data: data !== undefined});
|
217
235
|
return partials[name](context, options);
|
218
236
|
}
|
219
237
|
}
|
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.6.
|
4
|
+
version: 0.6.6
|
5
5
|
prerelease:
|
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: 2012-09-
|
12
|
+
date: 2012-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|