building-blocks 0.0.5 → 0.0.6

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.5
1
+ 0.0.6
@@ -190,23 +190,22 @@ module BuildingBlocks
190
190
  end
191
191
 
192
192
  def render_block(name_or_container, args, runtime_options={})
193
- # render_options = runtime_options
194
-
195
193
  buffer = ActionView::NonConcattingString.new
196
194
 
195
+ block_options = {}
197
196
  if (name_or_container.is_a?(BuildingBlocks::Container))
198
197
  name = name_or_container.name.to_sym
199
- # render_options = render_options.merge(name_or_container.options)
198
+ block_options = name_or_container.options
200
199
  else
201
200
  name = name_or_container.to_sym
202
201
  end
203
202
 
204
- buffer << render_before_blocks(name, runtime_options)
203
+ buffer << render_before_blocks(name_or_container, runtime_options)
205
204
 
206
205
  if blocks[name]
207
206
  block_container = blocks[name]
208
207
 
209
- args.push(global_options.merge(block_container.options).merge(runtime_options))
208
+ args.push(global_options.merge(block_container.options).merge(block_options).merge(runtime_options))
210
209
 
211
210
  # If the block is taking more than one parameter, we can use *args
212
211
  if block_container.block.arity > 1
@@ -220,7 +219,7 @@ module BuildingBlocks
220
219
  elsif view.blocks.blocks[name]
221
220
  block_container = view.blocks.blocks[name]
222
221
 
223
- args.push(global_options.merge(block_container.options).merge(runtime_options))
222
+ args.push(global_options.merge(block_container.options).merge(block_options).merge(runtime_options))
224
223
 
225
224
  # If the block is taking more than one parameter, we can use *args
226
225
  if block_container.block.arity > 1
@@ -234,24 +233,32 @@ module BuildingBlocks
234
233
  else
235
234
  begin
236
235
  begin
237
- buffer << view.render("#{name.to_s}", global_options.merge(runtime_options))
236
+ buffer << view.render("#{name.to_s}", global_options.merge(block_options).merge(runtime_options))
238
237
  rescue ActionView::MissingTemplate
239
238
  # 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(runtime_options))
239
+ buffer << view.render("#{self.global_options[:templates_folder]}/#{name.to_s}", global_options.merge(block_options).merge(runtime_options))
241
240
  end
242
241
  rescue ActionView::MissingTemplate
243
242
  # This block does not exist and no partial can be found to satify it
244
243
  end
245
244
  end
246
245
 
247
- buffer << render_after_blocks(name, runtime_options)
246
+ buffer << render_after_blocks(name_or_container, runtime_options)
248
247
 
249
248
  buffer
250
249
  end
251
250
 
252
- def render_before_blocks(name, runtime_options={})
251
+ def render_before_blocks(name_or_container, runtime_options={})
253
252
  options = global_options
254
253
 
254
+ block_options = {}
255
+ if (name_or_container.is_a?(BuildingBlocks::Container))
256
+ name = name_or_container.name.to_sym
257
+ block_options = name_or_container.options
258
+ else
259
+ name = name_or_container.to_sym
260
+ end
261
+
255
262
  before_name = "before_#{name.to_s}".to_sym
256
263
 
257
264
  if blocks[name]
@@ -268,22 +275,30 @@ module BuildingBlocks
268
275
 
269
276
  unless blocks[before_name].nil?
270
277
  blocks[before_name].each do |block_container|
271
- buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
278
+ buffer << view.capture(options.merge(block_container.options).merge(block_options).merge(runtime_options), &block_container.block)
272
279
  end
273
280
  end
274
281
 
275
282
  unless view.blocks.blocks[before_name].nil? || view.blocks.blocks == blocks
276
283
  view.blocks.blocks[before_name].each do |block_container|
277
- buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
284
+ buffer << view.capture(options.merge(block_container.options).merge(block_options).merge(runtime_options), &block_container.block)
278
285
  end
279
286
  end
280
287
 
281
288
  buffer
282
289
  end
283
290
 
284
- def render_after_blocks(name, runtime_options={})
291
+ def render_after_blocks(name_or_container, runtime_options={})
285
292
  options = global_options
286
293
 
294
+ block_options = {}
295
+ if (name_or_container.is_a?(BuildingBlocks::Container))
296
+ name = name_or_container.name.to_sym
297
+ block_options = name_or_container.options
298
+ else
299
+ name = name_or_container.to_sym
300
+ end
301
+
287
302
  after_name = "after_#{name.to_s}".to_sym
288
303
 
289
304
  if blocks[name]
@@ -300,13 +315,13 @@ module BuildingBlocks
300
315
 
301
316
  unless blocks[after_name].nil?
302
317
  blocks[after_name].each do |block_container|
303
- buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
318
+ buffer << view.capture(options.merge(block_container.options).merge(block_options).merge(runtime_options), &block_container.block)
304
319
  end
305
320
  end
306
321
 
307
322
  unless view.blocks.blocks[after_name].nil? || view.blocks.blocks == blocks
308
323
  view.blocks.blocks[after_name].each do |block_container|
309
- buffer << view.capture(options.merge(block_container.options).merge(runtime_options), &block_container.block)
324
+ buffer << view.capture(options.merge(block_container.options).merge(block_options).merge(runtime_options), &block_container.block)
310
325
  end
311
326
  end
312
327
 
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Hunter