sproutcore 0.9.11 → 0.9.12

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.
Files changed (88) hide show
  1. data/History.txt +98 -73
  2. data/Manifest.txt +2 -1
  3. data/README.txt +1 -1
  4. data/Rakefile +8 -8
  5. data/app_generators/sproutcore/USAGE +2 -3
  6. data/app_generators/sproutcore/sproutcore_generator.rb +12 -12
  7. data/app_generators/sproutcore/templates/README +26 -23
  8. data/app_generators/sproutcore/templates/{sc-config.rb → sc-config} +32 -17
  9. data/bin/sc-build +17 -17
  10. data/bin/sc-server +1 -1
  11. data/bin/sproutcore +3 -3
  12. data/clients/sc_test_runner/english.lproj/no_tests.rhtml +0 -1
  13. data/config/hoe.rb +9 -9
  14. data/config/requirements.rb +1 -1
  15. data/frameworks/sproutcore/HISTORY +14 -0
  16. data/frameworks/sproutcore/core.js +1 -1
  17. data/frameworks/sproutcore/english.lproj/theme.css +1 -0
  18. data/frameworks/sproutcore/foundation/binding.js +2 -2
  19. data/frameworks/sproutcore/foundation/timer.js +55 -22
  20. data/frameworks/sproutcore/lib/index.rhtml +2 -3
  21. data/frameworks/sproutcore/models/record.js +204 -63
  22. data/frameworks/sproutcore/tests/models/model.rhtml +360 -0
  23. data/frameworks/sproutcore/views/button/button.js +22 -1
  24. data/frameworks/sproutcore/views/collection/collection.js +6 -2
  25. data/frameworks/sproutcore/views/collection/list.js +1 -0
  26. data/frameworks/sproutcore/views/collection/source_list.js +1 -0
  27. data/frameworks/sproutcore/views/field/text_field.js +11 -2
  28. data/frameworks/sproutcore/views/inline_text_field.js +3 -2
  29. data/frameworks/sproutcore/views/menu_item.js +1 -0
  30. data/frameworks/sproutcore/views/pagination.js +1 -0
  31. data/frameworks/sproutcore/views/view.js +4 -1
  32. data/lib/sproutcore/build_tools/html_builder.rb +36 -36
  33. data/lib/sproutcore/build_tools/resource_builder.rb +55 -54
  34. data/lib/sproutcore/build_tools.rb +12 -12
  35. data/lib/sproutcore/bundle.rb +162 -164
  36. data/lib/sproutcore/bundle_manifest.rb +154 -107
  37. data/lib/sproutcore/generator_helper.rb +23 -23
  38. data/lib/sproutcore/helpers/capture_helper.rb +10 -10
  39. data/lib/sproutcore/helpers/static_helper.rb +39 -26
  40. data/lib/sproutcore/helpers/tag_helper.rb +10 -10
  41. data/lib/sproutcore/helpers/text_helper.rb +36 -36
  42. data/lib/sproutcore/helpers.rb +1 -1
  43. data/lib/sproutcore/jsdoc.rb +10 -10
  44. data/lib/sproutcore/jsmin.rb +14 -14
  45. data/lib/sproutcore/library.rb +135 -87
  46. data/lib/sproutcore/merb/bundle_controller.rb +77 -54
  47. data/lib/sproutcore/merb/router.rb +19 -12
  48. data/lib/sproutcore/merb.rb +1 -1
  49. data/lib/sproutcore/version.rb +1 -1
  50. data/lib/sproutcore/view_helpers.rb +121 -121
  51. data/lib/sproutcore.rb +5 -7
  52. data/sc-config.rb +6 -0
  53. data/sc_generators/client/README +1 -1
  54. data/sc_generators/client/USAGE +1 -2
  55. data/sc_generators/client/client_generator.rb +6 -6
  56. data/sc_generators/client/templates/core.js +2 -2
  57. data/sc_generators/client/templates/english.lproj/body.css +79 -81
  58. data/sc_generators/client/templates/english.lproj/strings.js +1 -2
  59. data/sc_generators/client/templates/main.js +6 -8
  60. data/sc_generators/controller/USAGE +1 -2
  61. data/sc_generators/controller/controller_generator.rb +7 -7
  62. data/sc_generators/controller/templates/controller.js +3 -3
  63. data/sc_generators/controller/templates/test.rhtml +1 -1
  64. data/sc_generators/framework/README +1 -2
  65. data/sc_generators/framework/USAGE +2 -3
  66. data/sc_generators/framework/framework_generator.rb +5 -5
  67. data/sc_generators/framework/templates/core.js +3 -3
  68. data/sc_generators/framework/templates/english.lproj/strings.js +1 -2
  69. data/sc_generators/language/USAGE +1 -2
  70. data/sc_generators/language/language_generator.rb +6 -6
  71. data/sc_generators/language/templates/strings.js +1 -2
  72. data/sc_generators/model/USAGE +1 -2
  73. data/sc_generators/model/model_generator.rb +7 -7
  74. data/sc_generators/model/templates/fixture.js +26 -26
  75. data/sc_generators/model/templates/model.js +5 -5
  76. data/sc_generators/model/templates/test.rhtml +2 -2
  77. data/sc_generators/test/USAGE +1 -2
  78. data/sc_generators/test/templates/test.rhtml +2 -2
  79. data/sc_generators/test/test_generator.rb +6 -6
  80. data/sc_generators/view/USAGE +1 -2
  81. data/sc_generators/view/templates/test.rhtml +2 -2
  82. data/sc_generators/view/templates/view.js +3 -3
  83. data/sc_generators/view/view_generator.rb +7 -7
  84. data/spec/spec.opts +1 -1
  85. data/spec/spec_helper.rb +1 -1
  86. data/spec/sproutcore_spec.rb +3 -3
  87. data/tasks/deployment.rake +4 -4
  88. metadata +4 -3
@@ -1,53 +1,53 @@
1
1
 
2
2
  module SproutCore
3
-
3
+
4
4
  # The PageHelper is a singleton object that can render the Page javascript
5
5
  # object.
6
6
  module PageHelper
7
-
7
+
8
8
  @@render_contexts = []
9
9
  @@outlets = {}
10
10
  @@outlet_names = []
11
11
  @@styles = []
12
12
  @@defines = {}
13
-
13
+
14
14
  # This is the current helper state used when rendering the HTML. When
15
15
  # a view helper is rendered, it may add itself as an outlet to the current
16
16
  # helper state instead of to the page helper.
17
17
  def self.current_render_context
18
18
  @@render_contexts.last
19
19
  end
20
-
20
+
21
21
  def self.push_render_context(state)
22
22
  @@render_contexts.push(state)
23
23
  end
24
-
24
+
25
25
  def self.pop_render_context
26
26
  @@render_contexts.pop
27
27
  end
28
-
28
+
29
29
  # reset the page helper.
30
30
  def self.reset!
31
31
  @@render_contexts = []
32
32
  @@outlets = {}
33
33
  @@outlet_names = []
34
- @@styles = []
34
+ @@styles = []
35
35
  @@defines = {}
36
36
  end
37
-
37
+
38
38
  def self.set_define(key, opts = {})
39
39
  @@defines[key] = opts
40
40
  end
41
-
41
+
42
42
  def self.set_outlet(key,opts = {})
43
43
  @@outlet_names << key
44
44
  @@outlets[key] = opts
45
45
  end
46
-
46
+
47
47
  def self.add_styles(styles)
48
48
  @@styles << styles
49
49
  end
50
-
50
+
51
51
  # renders the page object for the current page. If you include a prefix
52
52
  # that will be used to create a separate page object. Otherwise, the
53
53
  # object will live in the SC namespace.
@@ -61,7 +61,7 @@ module SproutCore
61
61
  outlet_path = opts[:outlet_path] || "##{opts[:id] || key}"
62
62
  outlets << %{ #{key}: #{opts[:class] || 'SC.View'}.extend({\n #{ opts[:properties].gsub("\n","\n ") }\n }).outletFor("#{outlet_path}") }
63
63
  end
64
-
64
+
65
65
  # defines let you define classes to include in your UI.
66
66
  ret = @@defines.map do | key, opts |
67
67
  %{#{key} = #{opts[:class] || 'SC.View'}.extend({\n #{ opts[:properties] }\n});}
@@ -70,7 +70,7 @@ module SproutCore
70
70
  return ret * "\n"
71
71
 
72
72
  end
73
-
73
+
74
74
  def self.render_css
75
75
  if @@styles.size > 0
76
76
  %(<style type="application/css">\n#{ @@styles * "\n" }\n</style>)
@@ -78,20 +78,20 @@ module SproutCore
78
78
  ''
79
79
  end
80
80
  end
81
-
81
+
82
82
  end
83
-
83
+
84
84
  module ViewHelperSupport
85
-
85
+
86
86
  @@helpers = {}
87
87
  def self.find_helper(helper_name)
88
88
  @@helpers[helper_name.to_sym] || @@helpers[:view]
89
89
  end
90
-
90
+
91
91
  def self.set_helper(helper_name,obj)
92
92
  @@helpers[helper_name.to_sym] = obj
93
93
  end
94
-
94
+
95
95
  class RenderContext
96
96
 
97
97
  # options passed in from the view helper
@@ -101,21 +101,21 @@ module SproutCore
101
101
  attr_accessor :current_helper
102
102
  attr_accessor :client_builder
103
103
  attr_reader :render_source
104
-
104
+
105
105
  def initialize(item_id, opts={}, client_builder = nil, render_source=nil)
106
106
  @_options = opts.dup
107
107
  @bindings = (@_options[:bind] || {}).dup
108
108
  @outlets = {}
109
109
  @prototypes = {}
110
110
  @item_id = item_id
111
- @outlet = opts[:outlet]
111
+ @outlet = opts[:outlet]
112
112
  @define = opts[:define]
113
- @client_builder = client_builder
113
+ @client_builder = client_builder
114
114
  @outlet_names = []
115
115
  @render_source = render_source
116
-
116
+
117
117
  @attributes = (@_options[:attributes] || {}).dup
118
-
118
+
119
119
  @_properties = {}
120
120
  if @_options[:properties]
121
121
  @_options[:properties].each do | key, value |
@@ -127,19 +127,19 @@ module SproutCore
127
127
  def options
128
128
  @_options
129
129
  end
130
-
130
+
131
131
  def set_outlet(key,opts = {})
132
132
  @outlet_names << key
133
133
  @outlets[key] = opts
134
134
  end
135
-
135
+
136
136
  def prepare_bindings
137
137
  @bindings.each do | k,v |
138
138
  key = k.to_s.camelize(:lower) + 'Binding'
139
139
  @_properties[key] = v.include?('(') ? v : prepare_for_javascript(v)
140
140
  end
141
141
  end
142
-
142
+
143
143
  def prepare_outlets
144
144
  return if @outlets.size == 0
145
145
  outlets = []
@@ -155,35 +155,35 @@ module SproutCore
155
155
 
156
156
  @_properties['outlets'] = outlets
157
157
  end
158
-
158
+
159
159
  def parent_helper(opts = {})
160
160
  if @current_helper && @current_helper.parent_helper
161
161
  @_options.merge! opts
162
162
  @current_helper.parent_helper.prepare_context(self)
163
163
  end
164
164
  end
165
-
165
+
166
166
  ### RENDER METHODS
167
167
  def render_content
168
168
  @attributes[:id] = @item_id if @item_id && !(@outlet || @define)
169
-
169
+
170
170
  old_client_builder = self.client_builder
171
171
  self.client_builder = @content_render_client_builder unless @content_render_client_builder.nil?
172
172
  ret = _do_render(@content_render)
173
173
  self.client_builder = old_client_builder
174
- return ret
174
+ return ret
175
175
  end
176
-
176
+
177
177
  def render_view
178
178
  prepare_bindings
179
179
  prepare_outlets
180
180
  _do_render(@view_render)
181
181
  end
182
-
182
+
183
183
  def view_class
184
184
  @view_class
185
185
  end
186
-
186
+
187
187
  def render_styles
188
188
  _do_render(@styles_render)
189
189
  end
@@ -212,16 +212,16 @@ module SproutCore
212
212
  def static_url(resource_name, opts = {})
213
213
  opts[:language] ||= @language
214
214
  entry = @client_builder.find_resource_entry(resource_name, opts)
215
- entry.nil? ? '' : entry.url
215
+ entry.nil? ? '' : entry.cacheable_url
216
216
  end
217
-
217
+
218
218
  def blank_url
219
219
  static_url('blank.gif')
220
220
  end
221
-
221
+
222
222
  ### HTML HELPER METHODS
223
-
224
- # This will extract the specified value and put it into an ivar you can
223
+
224
+ # This will extract the specified value and put it into an ivar you can
225
225
  # access later during rendering. For example:
226
226
  #
227
227
  # var :label, 'Default label'
@@ -230,40 +230,40 @@ module SproutCore
230
230
  #
231
231
  # Parameters:
232
232
  # option_key: (req) the option to map.
233
- # default_value: (opt) if passed, this will be used as the default value
233
+ # default_value: (opt) if passed, this will be used as the default value
234
234
  # if the option is not passed in.
235
- #
236
- # :key => (opt) the name of the resulting ivar. defaults to the option
237
- # key.
235
+ #
236
+ # :key => (opt) the name of the resulting ivar. defaults to the option
237
+ # key.
238
238
  #
239
239
  # :optional => (opt) if true, then the attribute will not be included if
240
- # it is not explicitly passed in the options. if no default value is
241
- # specified, then this will default to true, otherwise defaults to
240
+ # it is not explicitly passed in the options. if no default value is
241
+ # specified, then this will default to true, otherwise defaults to
242
242
  # false.
243
- #
244
- # :constant => (opt) if true, then any passed in options will be ignored
245
- # for this key and the default you specify will be used instead.
243
+ #
244
+ # :constant => (opt) if true, then any passed in options will be ignored
245
+ # for this key and the default you specify will be used instead.
246
246
  # Defaults to false
247
247
  #
248
- # you may also pass a block that will be used to compute the value at
248
+ # you may also pass a block that will be used to compute the value at
249
249
  # render time. Expect a single parameter which is the initial value.
250
250
  #
251
251
  def var(option_key, default_value=:__UNDEFINED__, opts={}, &block)
252
252
  ret = _pair(option_key, default_value, opts, &block)
253
253
  return if ret[2] # ignore
254
254
  instance_variable_set("@#{ret[0]}".to_sym, ret[1])
255
- ret[1]
255
+ ret[1]
256
256
  end
257
-
257
+
258
258
  # returns the standard attributes for the HTML. This will automatically
259
259
  # include the item id. You can also declare added attributes using the
260
260
  # attribute param.
261
261
  def attributes
262
262
  final_class_names = css_class_names
263
263
  final_styles = css_styles
264
-
265
- ret = @attributes.map do |key,value|
266
-
264
+
265
+ ret = @attributes.map do |key,value|
266
+
267
267
  # if the css class or css style is declared, replace the current
268
268
  # set coming from the view_helper
269
269
  if key.to_sym == :class && value
@@ -276,25 +276,25 @@ module SproutCore
276
276
  value ? %(#{key}="#{value}") : nil
277
277
  end
278
278
  end
279
-
279
+
280
280
  # add in class names
281
- final_class_names = [final_class_names].flatten
281
+ final_class_names = [final_class_names].flatten
282
282
  final_class_names << @item_id
283
283
  final_class_names.compact!
284
284
  unless final_class_names.empty?
285
285
  ret << %(class="#{final_class_names.uniq * ' '}")
286
286
  end
287
-
287
+
288
288
  # add in styles
289
289
  unless final_styles.nil?
290
290
  final_styles = [final_styles].flatten
291
291
  final_styles.compact!
292
292
  ret << %(style="#{final_styles.uniq * ' '}") unless final_styles.empty?
293
293
  end
294
-
294
+
295
295
  ret.compact * ' '
296
296
  end
297
-
297
+
298
298
  # Your view helper can add text to by appended to the styles attribute
299
299
  # by adding to this array.
300
300
  def css_styles
@@ -304,49 +304,49 @@ module SproutCore
304
304
  def css_styles=(new_ary)
305
305
  @css_styles = new_ary
306
306
  end
307
-
308
- # Your view helper can add css classes to be appended to the classes
307
+
308
+ # Your view helper can add css classes to be appended to the classes
309
309
  # attribute by adding to this array.
310
310
  def css_class_names
311
311
  @css_class_names ||= []
312
312
  end
313
-
313
+
314
314
  def css_class_names=(new_ary)
315
315
  @css_class_names = new_ary
316
316
  end
317
-
317
+
318
318
  # This does the standard open tag with the default tag and attributes. Usually
319
319
  # you can use this.
320
320
  def open_tag
321
321
  %{<#{@tag} #{attributes}>}
322
322
  end
323
323
  alias_method :ot, :open_tag
324
-
324
+
325
325
  def close_tag
326
326
  %{</#{@tag}>}
327
327
  end
328
328
  alias_method :ct, :close_tag
329
-
329
+
330
330
  # Call this method in your view helper definition to map an option to
331
- # an attribute. This attribute can then be rendered with attributes.
331
+ # an attribute. This attribute can then be rendered with attributes.
332
332
  # This method takes the same options as var
333
333
  def attribute(option_key, default_value=:__UNDEFINED__, opts={}, &block)
334
334
  ret = _pair(option_key, default_value, opts, &block)
335
335
  return if ret[2] # ignore
336
336
  @attributes[ret[0]] = ret[1]
337
337
  end
338
-
338
+
339
339
  # returns all the JS properties specified by the property method.
340
340
  def properties
341
341
  keys = @_properties.keys
342
342
  ret = []
343
-
343
+
344
344
  # example element, if there is one
345
345
  if @define
346
346
  @_properties['emptyElement'] = %($sel("#resources? .#{@item_id}:1:1"))
347
347
  ret << _partial_properties(['emptyElement'])
348
348
  end
349
-
349
+
350
350
  # outlets first
351
351
  if keys.include?('outlets')
352
352
  outlets = @_properties['outlets']
@@ -355,21 +355,21 @@ module SproutCore
355
355
  ret << _partial_properties(outlets,",\n\n")
356
356
  keys.reject! { |k| outlets.include?(k) || (k == 'outlets') }
357
357
  end
358
-
358
+
359
359
  bindings = keys.reject { |k| !k.match(/Binding$/) }
360
360
  if bindings.size > 0
361
361
  ret << _partial_properties(bindings)
362
362
  keys.reject! { |k| bindings.include?(k) }
363
363
  end
364
-
364
+
365
365
  if keys.size > 0
366
366
  ret << _partial_properties(keys)
367
367
  end
368
-
368
+
369
369
  ret = ret * ",\n\n"
370
370
  ' ' + ret.gsub("\n","\n ")
371
371
  end
372
-
372
+
373
373
  def _partial_properties(keys,join = ",\n")
374
374
  ret = keys.map do |key|
375
375
  value = @_properties[key]
@@ -378,15 +378,15 @@ module SproutCore
378
378
  end
379
379
  ret * join
380
380
  end
381
-
381
+
382
382
  # Call this method to make a binding available or to set a default
383
- # binding. You can use this for properties you want to allow a
383
+ # binding. You can use this for properties you want to allow a
384
384
  # binding for but don't want to take as a fully property.
385
385
  def bind(option_key, default_value=:__UNDEFINED__, opts={})
386
- key, v, ignore = _pair(option_key, default_value, opts, false)
386
+ key, v, ignore = _pair(option_key, default_value, opts, false)
387
387
 
388
388
  # always look for the option key in the bindings passed by the user.
389
- # if present, this should override whatever we set
389
+ # if present, this should override whatever we set
390
390
  if found = @bindings[option_key.to_sym] || @bindings[option_key.to_s]
391
391
  v = found
392
392
  ignore = false
@@ -397,16 +397,16 @@ module SproutCore
397
397
  # finally, set the binding value.
398
398
  unless ignore
399
399
  v = v.include?('(') ? v : prepare_for_javascript(v)
400
- @_properties["#{key.camelize(:lower)}Binding"] = v
400
+ @_properties["#{key.camelize(:lower)}Binding"] = v
401
401
  end
402
402
 
403
403
  end
404
-
405
- # Call this method in your view helper to specify a property you want
406
- # added to the javascript declaration. This methos take the same
407
- # options as var. Note that normally the type of value returned here
408
- # will be marshalled into the proper type for JavaScript. If you
409
- # provide a block to compute the property, however, the value will be
404
+
405
+ # Call this method in your view helper to specify a property you want
406
+ # added to the javascript declaration. This methos take the same
407
+ # options as var. Note that normally the type of value returned here
408
+ # will be marshalled into the proper type for JavaScript. If you
409
+ # provide a block to compute the property, however, the value will be
410
410
  # inserted directly.
411
411
  def property(option_key, default_value=:__UNDEFINED__, opts={}, &block)
412
412
  ret = _pair(option_key, default_value, opts, &block)
@@ -417,7 +417,7 @@ module SproutCore
417
417
  value = prepare_for_javascript(value) unless block_given?
418
418
  @_properties[key] = value
419
419
  end
420
-
420
+
421
421
  # also look for a matching binding and set it needed.
422
422
  if v = @bindings[option_key.to_sym] || @bindings[option_key.to_s]
423
423
  v = v.include?('(') ? v : prepare_for_javascript(v)
@@ -425,7 +425,7 @@ module SproutCore
425
425
  @bindings.delete option_key.to_sym
426
426
  @bindings.delete option_key.to_s
427
427
  end
428
-
428
+
429
429
  end
430
430
 
431
431
  def prepare_for_javascript(value)
@@ -450,10 +450,10 @@ module SproutCore
450
450
  value.to_s
451
451
  end
452
452
  end
453
-
453
+
454
454
  ### INTERNAL SUPPORT
455
455
  private
456
-
456
+
457
457
  def _do_render(render_item)
458
458
  if render_item.nil?
459
459
  ''
@@ -463,8 +463,8 @@ module SproutCore
463
463
  render_item
464
464
  end
465
465
  end
466
-
467
- def _pair(option_key, default_value, opts, look_for_key = true)
466
+
467
+ def _pair(option_key, default_value, opts, look_for_key = true)
468
468
  if default_value.instance_of?(Hash)
469
469
  opts = default_value
470
470
  default_value = :__UNDEFINED__
@@ -481,8 +481,8 @@ module SproutCore
481
481
  else
482
482
  value = default_value
483
483
  end
484
-
485
-
484
+
485
+
486
486
  if (optional==true) && value == :__UNDEFINED__
487
487
  ignore = true
488
488
  value = nil
@@ -491,39 +491,39 @@ module SproutCore
491
491
  value = nil if value == :__UNDEFINED__
492
492
  value = yield(value) if block_given?
493
493
  end
494
-
494
+
495
495
  attr_key = (opts[:key] || option_key).to_s
496
496
  [attr_key, value, ignore]
497
497
  end
498
-
498
+
499
499
  end
500
500
 
501
501
  class HelperState
502
502
  attr_reader :name
503
503
  attr_reader :parent_helper
504
504
  attr_reader :prepare_block
505
-
505
+
506
506
  def initialize(helper_name, opts={}, &block)
507
507
  @name = helper_name
508
508
  @prepare_block = block
509
509
  @parent_helper = SproutCore::ViewHelperSupport.find_helper(opts[:wraps] || opts[:extends] || :view)
510
510
  @extends = opts[:wraps].nil?
511
511
  end
512
-
512
+
513
513
  def prepare_context(render_context)
514
- # automatically call parent helper if extends was used.
514
+ # automatically call parent helper if extends was used.
515
515
  if parent_helper && @extends
516
516
  parent_helper.prepare_context(render_context)
517
517
  else
518
518
  render_context.current_helper = self
519
519
  end
520
-
520
+
521
521
  render_context.instance_eval &prepare_block
522
522
  render_context.current_helper = nil
523
523
  end
524
-
524
+
525
525
  end
526
-
526
+
527
527
  @@tick = 0
528
528
  def self._gen_id(type="id")
529
529
  @@tick += 1
@@ -532,11 +532,11 @@ module SproutCore
532
532
 
533
533
  extend SproutCore::Helpers::CaptureHelper
534
534
  extend SproutCore::Helpers::TextHelper
535
-
535
+
536
536
  # :outlet => define if you want this to be used as an outlet.
537
537
  # :prototype => define if you want this to be used as a prototype.
538
538
  def self.render_view(view_helper_id, item_id, opts={}, client_builder=nil, render_source=nil, &block)
539
-
539
+
540
540
  # item_id is optional. If it is not a symbol or string, then generate
541
541
  # an item_id
542
542
  if item_id.instance_of?(Hash)
@@ -548,27 +548,27 @@ module SproutCore
548
548
  client_builder = opts[:client] if opts[:client]
549
549
  rc = RenderContext.new(item_id, opts, client_builder, render_source)
550
550
  hs = find_helper(view_helper_id)
551
-
551
+
552
552
  # render the inner_html using the block, if one is given.
553
553
  SproutCore::PageHelper.push_render_context(rc)
554
554
  rc.options[:inner_html] = capture(&block) if block_given?
555
-
555
+
556
556
  # now, use the helper state to prepare the render context. This will
557
557
  # extract the properties from the options and setup the render procs.
558
558
  hs.prepare_context(rc) unless hs.nil?
559
-
559
+
560
560
  # how have the render context render the HTML content. This may also
561
561
  # make changes to the other items to render.
562
562
  ret = rc.render_content
563
563
 
564
564
  SproutCore::PageHelper.pop_render_context
565
-
565
+
566
566
  # get the JS. Save as an outlet or in the page.
567
567
  cur_rc = SproutCore::PageHelper.current_render_context
568
568
  view_class = opts[:view] || rc.view_class
569
569
  unless view_class.nil?
570
570
  view_settings = { :id => item_id, :class => view_class, :properties => rc.render_view, :lazy => opts[:lazy], :outlet_path => opts[:outlet_path] }
571
-
571
+
572
572
  # if an outlet item is passed, then register this as an outlet.
573
573
  outlet = opts[:outlet] || rc.outlet
574
574
  define = opts[:define]
@@ -579,21 +579,21 @@ module SproutCore
579
579
  elsif define
580
580
  define = define.to_s.camelize.gsub('::','.')
581
581
  SproutCore::PageHelper.set_define(define, view_settings)
582
-
582
+
583
583
  # otherwise, add it to the page-wide setting.
584
584
  else
585
585
  prop = item_id.to_s.camelize(:lower)
586
586
  SproutCore::PageHelper.set_outlet(prop, view_settings)
587
587
  end
588
588
  end
589
-
589
+
590
590
  # get the styles, if any
591
591
  styles = rc.render_styles
592
- SproutCore::PageHelper.add_styles(styles) if styles && styles.size > 0
593
-
592
+ SproutCore::PageHelper.add_styles(styles) if styles && styles.size > 0
593
+
594
594
  # done. return the generated HTML
595
- concat(ret,block) if block_given?
596
- return ret
595
+ concat(ret,block) if block_given?
596
+ return ret
597
597
  end
598
598
 
599
599
  end
@@ -611,17 +611,17 @@ module SproutCore
611
611
  end }
612
612
 
613
613
  end
614
-
614
+
615
615
  def render_page_views
616
616
  ret = %(<script type="text/javascript">\n#{SproutCore::PageHelper.render_js}\n</script>)
617
617
  SproutCore::PageHelper.reset!
618
- return ret
618
+ return ret
619
619
  end
620
620
 
621
621
  # Call this method to load a helper. This will get the file contents
622
622
  # and eval it.
623
623
  def require_helpers(helper_name, bundle=nil)
624
-
624
+
625
625
  # save bundle for future use
626
626
  unless bundle.nil?
627
627
  old_helper_bundle = @helper_bundle
@@ -635,24 +635,24 @@ module SproutCore
635
635
  paths = [@helper_bundle.helper_for(helper_name)]
636
636
  end
637
637
  paths.compact!
638
-
638
+
639
639
  # Create list of loaded helper paths
640
640
  @loaded_helpers = [] if @loaded_helpers.nil?
641
-
641
+
642
642
  # If a helper path was found, load it. May require other helpers
643
643
  paths.each do |path|
644
644
  next if @loaded_helpers.include?(path)
645
645
  @loaded_helpers << path
646
-
646
+
647
647
  eval(@helper_bundle.helper_contents_for(path))
648
648
  end
649
-
649
+
650
650
  # restore old bundle helper.
651
651
  unless bundle.nil?
652
652
  @helper_bundle = old_helper_bundle
653
653
  end
654
654
  end
655
-
655
+
656
656
  end
657
-
657
+
658
658
  end
data/lib/sproutcore.rb CHANGED
@@ -3,21 +3,21 @@ $:.unshift File.dirname(__FILE__)
3
3
  require 'rubygems'
4
4
  require 'activesupport'
5
5
 
6
- module SproutCore
6
+ module SproutCore
7
7
 
8
- # Returns a library for the current working directory. This is useful when
8
+ # Returns a library for the current working directory. This is useful when
9
9
  # working on the command line
10
10
  def self.library
11
11
  Library.library_for(Dir.pwd)
12
12
  end
13
-
13
+
14
14
  def self.library_for(path, opts={})
15
15
  Library.library_for(path, opts)
16
16
  end
17
-
17
+
18
18
  def self.logger; @logger ||= Logger.new(STDOUT); end
19
19
  def self.logger=(new_logger); @logger = new_logger; end
20
-
20
+
21
21
  end
22
22
 
23
23
  # Force load the code files. Others may be loaded only as required
@@ -26,5 +26,3 @@ end
26
26
  end
27
27
 
28
28
  SC= SproutCore
29
-
30
-