steering-rails 1.0.0

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.
@@ -0,0 +1,223 @@
1
+ // lib/handlebars/base.js
2
+ var Handlebars = {};
3
+
4
+ Handlebars.VERSION = "1.0.beta.6";
5
+
6
+ Handlebars.helpers = {};
7
+ Handlebars.partials = {};
8
+
9
+ Handlebars.registerHelper = function(name, fn, inverse) {
10
+ if(inverse) { fn.not = inverse; }
11
+ this.helpers[name] = fn;
12
+ };
13
+
14
+ Handlebars.registerPartial = function(name, str) {
15
+ this.partials[name] = str;
16
+ };
17
+
18
+ Handlebars.registerHelper('helperMissing', function(arg) {
19
+ if(arguments.length === 2) {
20
+ return undefined;
21
+ } else {
22
+ throw new Error("Could not find property '" + arg + "'");
23
+ }
24
+ });
25
+
26
+ var toString = Object.prototype.toString, functionType = "[object Function]";
27
+
28
+ Handlebars.registerHelper('blockHelperMissing', function(context, options) {
29
+ var inverse = options.inverse || function() {}, fn = options.fn;
30
+
31
+
32
+ var ret = "";
33
+ var type = toString.call(context);
34
+
35
+ if(type === functionType) { context = context.call(this); }
36
+
37
+ if(context === true) {
38
+ return fn(this);
39
+ } else if(context === false || context == null) {
40
+ return inverse(this);
41
+ } else if(type === "[object Array]") {
42
+ if(context.length > 0) {
43
+ for(var i=0, j=context.length; i<j; i++) {
44
+ ret = ret + fn(context[i]);
45
+ }
46
+ } else {
47
+ ret = inverse(this);
48
+ }
49
+ return ret;
50
+ } else {
51
+ return fn(context);
52
+ }
53
+ });
54
+
55
+ Handlebars.registerHelper('each', function(context, options) {
56
+ var fn = options.fn, inverse = options.inverse;
57
+ var ret = "";
58
+
59
+ if(context && context.length > 0) {
60
+ for(var i=0, j=context.length; i<j; i++) {
61
+ ret = ret + fn(context[i]);
62
+ }
63
+ } else {
64
+ ret = inverse(this);
65
+ }
66
+ return ret;
67
+ });
68
+
69
+ Handlebars.registerHelper('if', function(context, options) {
70
+ var type = toString.call(context);
71
+ if(type === functionType) { context = context.call(this); }
72
+
73
+ if(!context || Handlebars.Utils.isEmpty(context)) {
74
+ return options.inverse(this);
75
+ } else {
76
+ return options.fn(this);
77
+ }
78
+ });
79
+
80
+ Handlebars.registerHelper('unless', function(context, options) {
81
+ var fn = options.fn, inverse = options.inverse;
82
+ options.fn = inverse;
83
+ options.inverse = fn;
84
+
85
+ return Handlebars.helpers['if'].call(this, context, options);
86
+ });
87
+
88
+ Handlebars.registerHelper('with', function(context, options) {
89
+ return options.fn(context);
90
+ });
91
+
92
+ Handlebars.registerHelper('log', function(context) {
93
+ Handlebars.log(context);
94
+ });
95
+ ;
96
+ // lib/handlebars/utils.js
97
+ Handlebars.Exception = function(message) {
98
+ var tmp = Error.prototype.constructor.apply(this, arguments);
99
+
100
+ for (var p in tmp) {
101
+ if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
102
+ }
103
+
104
+ this.message = tmp.message;
105
+ };
106
+ Handlebars.Exception.prototype = new Error;
107
+
108
+ // Build out our basic SafeString type
109
+ Handlebars.SafeString = function(string) {
110
+ this.string = string;
111
+ };
112
+ Handlebars.SafeString.prototype.toString = function() {
113
+ return this.string.toString();
114
+ };
115
+
116
+ (function() {
117
+ var escape = {
118
+ "<": "&lt;",
119
+ ">": "&gt;",
120
+ '"': "&quot;",
121
+ "'": "&#x27;",
122
+ "`": "&#x60;"
123
+ };
124
+
125
+ var badChars = /&(?!\w+;)|[<>"'`]/g;
126
+ var possible = /[&<>"'`]/;
127
+
128
+ var escapeChar = function(chr) {
129
+ return escape[chr] || "&amp;";
130
+ };
131
+
132
+ Handlebars.Utils = {
133
+ escapeExpression: function(string) {
134
+ // don't escape SafeStrings, since they're already safe
135
+ if (string instanceof Handlebars.SafeString) {
136
+ return string.toString();
137
+ } else if (string == null || string === false) {
138
+ return "";
139
+ }
140
+
141
+ if(!possible.test(string)) { return string; }
142
+ return string.replace(badChars, escapeChar);
143
+ },
144
+
145
+ isEmpty: function(value) {
146
+ if (typeof value === "undefined") {
147
+ return true;
148
+ } else if (value === null) {
149
+ return true;
150
+ } else if (value === false) {
151
+ return true;
152
+ } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
153
+ return true;
154
+ } else {
155
+ return false;
156
+ }
157
+ }
158
+ };
159
+ })();;
160
+ // lib/handlebars/runtime.js
161
+ Handlebars.VM = {
162
+ template: function(templateSpec) {
163
+ // Just add water
164
+ var container = {
165
+ escapeExpression: Handlebars.Utils.escapeExpression,
166
+ invokePartial: Handlebars.VM.invokePartial,
167
+ programs: [],
168
+ program: function(i, fn, data) {
169
+ var programWrapper = this.programs[i];
170
+ if(data) {
171
+ return Handlebars.VM.program(fn, data);
172
+ } else if(programWrapper) {
173
+ return programWrapper;
174
+ } else {
175
+ programWrapper = this.programs[i] = Handlebars.VM.program(fn);
176
+ return programWrapper;
177
+ }
178
+ },
179
+ programWithDepth: Handlebars.VM.programWithDepth,
180
+ noop: Handlebars.VM.noop
181
+ };
182
+
183
+ return function(context, options) {
184
+ options = options || {};
185
+ return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
186
+ };
187
+ },
188
+
189
+ programWithDepth: function(fn, data, $depth) {
190
+ var args = Array.prototype.slice.call(arguments, 2);
191
+
192
+ return function(context, options) {
193
+ options = options || {};
194
+
195
+ return fn.apply(this, [context, options.data || data].concat(args));
196
+ };
197
+ },
198
+ program: function(fn, data) {
199
+ return function(context, options) {
200
+ options = options || {};
201
+
202
+ return fn(context, options.data || data);
203
+ };
204
+ },
205
+ noop: function() { return ""; },
206
+ invokePartial: function(partial, name, context, helpers, partials, data) {
207
+ options = { helpers: helpers, partials: partials, data: data };
208
+
209
+ if(partial === undefined) {
210
+ throw new Handlebars.Exception("The partial " + name + " could not be found");
211
+ } else if(partial instanceof Function) {
212
+ return partial(context, options);
213
+ } else if (!Handlebars.compile) {
214
+ throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
215
+ } else {
216
+ partials[name] = Handlebars.compile(partial);
217
+ return partials[name](context, options);
218
+ }
219
+ }
220
+ };
221
+
222
+ Handlebars.template = Handlebars.VM.template;
223
+ ;
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: steering-rails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Andrew White
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-21 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: sprockets
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 1
29
+ segments:
30
+ - 2
31
+ - 1
32
+ version: "2.1"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: railties
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 5
44
+ segments:
45
+ - 3
46
+ - 1
47
+ version: "3.1"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: steering
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 0
62
+ version: "1.0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ description: Precompiled Handlebars.js templates for the Rails asset pipeline
66
+ email:
67
+ - andyw@pixeltrix.co.uk
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - .gitignore
76
+ - Gemfile
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - lib/steering-rails.rb
81
+ - lib/steering/rails.rb
82
+ - lib/steering/rails/engine.rb
83
+ - lib/steering/rails/template.rb
84
+ - lib/steering/rails/version.rb
85
+ - steering-rails.gemspec
86
+ - vendor/assets/javascripts/handlebars.js
87
+ - vendor/assets/javascripts/handlebars.runtime.js
88
+ homepage: https://github.com/pixeltrix/steering-rails
89
+ licenses: []
90
+
91
+ post_install_message:
92
+ rdoc_options: []
93
+
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ requirements: []
115
+
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.14
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: Precompiled Handlebars.js templates for the Rails asset pipeline
121
+ test_files: []
122
+