building-blocks 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -189,24 +189,24 @@ module BuildingBlocks
189
189
  "block_#{anonymous_block_number}"
190
190
  end
191
191
 
192
- def render_block(name_or_container, args, options={})
193
- render_options = options
192
+ def render_block(name_or_container, args, runtime_options={})
193
+ # render_options = runtime_options
194
194
 
195
195
  buffer = ActionView::NonConcattingString.new
196
196
 
197
197
  if (name_or_container.is_a?(BuildingBlocks::Container))
198
198
  name = name_or_container.name.to_sym
199
- render_options = render_options.merge(name_or_container.options)
199
+ # render_options = render_options.merge(name_or_container.options)
200
200
  else
201
201
  name = name_or_container.to_sym
202
202
  end
203
203
 
204
- buffer << render_before_blocks(name, options)
204
+ buffer << render_before_blocks(name, runtime_options)
205
205
 
206
206
  if blocks[name]
207
207
  block_container = blocks[name]
208
208
 
209
- args.push(global_options.merge(block_container.options).merge(render_options))
209
+ args.push(global_options.merge(block_container.options).merge(runtime_options))
210
210
 
211
211
  # If the block is taking more than one parameter, we can use *args
212
212
  if block_container.block.arity > 1
@@ -220,7 +220,7 @@ module BuildingBlocks
220
220
  elsif view.blocks.blocks[name]
221
221
  block_container = view.blocks.blocks[name]
222
222
 
223
- args.push(global_options.merge(block_container.options).merge(render_options))
223
+ args.push(global_options.merge(block_container.options).merge(runtime_options))
224
224
 
225
225
  # If the block is taking more than one parameter, we can use *args
226
226
  if block_container.block.arity > 1
@@ -234,55 +234,79 @@ module BuildingBlocks
234
234
  else
235
235
  begin
236
236
  begin
237
- buffer << view.render("#{name.to_s}", global_options.merge(render_options))
237
+ buffer << view.render("#{name.to_s}", global_options.merge(runtime_options))
238
238
  rescue ActionView::MissingTemplate
239
239
  # This partial did not exist in the current controller's view directory; now checking in the default templates folder
240
- buffer << view.render("#{self.global_options[:templates_folder]}/#{name.to_s}", global_options.merge(render_options))
240
+ buffer << view.render("#{self.global_options[:templates_folder]}/#{name.to_s}", global_options.merge(runtime_options))
241
241
  end
242
242
  rescue ActionView::MissingTemplate
243
243
  # This block does not exist and no partial can be found to satify it
244
244
  end
245
245
  end
246
246
 
247
- buffer << render_after_blocks(name, options)
247
+ buffer << render_after_blocks(name, runtime_options)
248
248
 
249
249
  buffer
250
250
  end
251
251
 
252
- def render_before_blocks(name, options={})
253
- name = "before_#{name.to_s}".to_sym
252
+ def render_before_blocks(name, runtime_options={})
253
+ options = global_options
254
+
255
+ before_name = "before_#{name.to_s}".to_sym
256
+
257
+ if blocks[name]
258
+ block_container = blocks[name]
259
+
260
+ options = options.merge(block_container.options)
261
+ elsif view.blocks.blocks[name]
262
+ block_container = view.blocks.blocks[name]
263
+
264
+ options = options.merge(block_container.options)
265
+ end
254
266
 
255
267
  buffer = ActionView::NonConcattingString.new
256
268
 
257
- unless blocks[name].nil?
258
- blocks[name].each do |block_container|
259
- buffer << view.capture(global_options.merge(block_container.options).merge(options), &block_container.block)
269
+ unless blocks[before_name].nil?
270
+ blocks[before_name].each do |block_container|
271
+ buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
260
272
  end
261
273
  end
262
274
 
263
- unless view.blocks.blocks[name].nil? || view.blocks.blocks == blocks
264
- view.blocks.blocks[name].each do |block_container|
265
- buffer << view.capture(global_options.merge(block_container.options).merge(options), &block_container.block)
275
+ unless view.blocks.blocks[before_name].nil? || view.blocks.blocks == blocks
276
+ view.blocks.blocks[before_name].each do |block_container|
277
+ buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
266
278
  end
267
279
  end
268
280
 
269
281
  buffer
270
282
  end
271
283
 
272
- def render_after_blocks(name, options={})
273
- name = "after_#{name.to_s}".to_sym
284
+ def render_after_blocks(name, runtime_options={})
285
+ options = global_options
286
+
287
+ after_name = "after_#{name.to_s}".to_sym
288
+
289
+ if blocks[name]
290
+ block_container = blocks[name]
291
+
292
+ options = options.merge(block_container.options)
293
+ elsif view.blocks.blocks[name]
294
+ block_container = view.blocks.blocks[name]
295
+
296
+ options = options.merge(block_container.options)
297
+ end
274
298
 
275
299
  buffer = ActionView::NonConcattingString.new
276
300
 
277
- unless blocks[name].nil?
278
- blocks[name].each do |block_container|
279
- buffer << view.capture(global_options.merge(block_container.options).merge(options), &block_container.block)
301
+ unless blocks[after_name].nil?
302
+ blocks[after_name].each do |block_container|
303
+ buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
280
304
  end
281
305
  end
282
306
 
283
- unless view.blocks.blocks[name].nil? || view.blocks.blocks == blocks
284
- view.blocks.blocks[name].each do |block_container|
285
- buffer << view.capture(global_options.merge(block_container.options).merge(options), &block_container.block)
307
+ unless view.blocks.blocks[after_name].nil? || view.blocks.blocks == blocks
308
+ view.blocks.blocks[after_name].each do |block_container|
309
+ buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
286
310
  end
287
311
  end
288
312
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: building-blocks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Hunter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-16 00:00:00 -04:00
18
+ date: 2011-06-07 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency