blocks 2.6.4 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +8 -1
- data/Rakefile +2 -2
- data/lib/blocks.rb +3 -2
- data/lib/blocks/base.rb +25 -10
- data/lib/blocks/version.rb +2 -2
- data/lib/blocks/view_additions.rb +6 -8
- data/spec/blocks/base_spec.rb +31 -31
- data/spec/blocks/view_additions_spec.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWI0ZTBkM2RiYWJjMzkxM2NiNTQ0NDEyYjY5MzIyNjI0YWNlMTZmNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmFiNDE4Yjg5OTBiYTg5YmQwZTQxZWU1ZmEzOGQ2ZjIzNDNhYWQzYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjAyM2ZjYWZmMzc1MDM1ZjkyY2FmMTdhYTYyOTk0OTgwMzBhMmRmNDJhMjdi
|
10
|
+
ZWE0NDFkZDM2NjVjYTgxZWRjNjVlYTUyNjZkMTlhMTk1YWUzMWIzMDkwN2M1
|
11
|
+
N2IyYjQ3NDU2MWIyMGVkYWZkMDA4YTEzOGNlMjgzNzAzNDY5YzA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2MyNmEwMTMwNzllYjZlZWVkNjQ2MGE2MWIyMDNmYzI5NGNkMDQ1ODU3NTFj
|
14
|
+
YTJhZjk0YjgwYThiM2I5MjA5M2E2ZTdiZTIwOWFjODYzMzRhZjQ1MTk1Nzgw
|
15
|
+
Y2QxNzYyN2EzOWFiNzU0NGRkZGYzN2YyYzMzOTIwYTc2ZWMzYjk=
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2.7.0 (December 9, 2015)
|
2
|
+
* Added configuration option skip_applies_to_surrounding_blocks. When set to true, if blocks.skip :SOME_BLOCK is called,
|
3
|
+
any before, after, and around hooks applied to that block will also be skipped when the block attempts to render.
|
4
|
+
This may be configured in an initializer as follows:
|
5
|
+
Blocks.setup { |config| config.skip_applies_to_surrounding_blocks = true }
|
6
|
+
* Cleanup to Blocks::Base to reduce code duplication
|
7
|
+
|
1
8
|
2.6.4 (July 21, 2014)
|
2
9
|
* Removed dependence on jeweler for managing gem
|
3
10
|
* Small cleanups of the code
|
@@ -83,4 +90,4 @@
|
|
83
90
|
* Ability to disable use of partials when rendering a block
|
84
91
|
* Ability to disable use of partials for before and after hooks
|
85
92
|
* Complete test coverage
|
86
|
-
* :template_folder and :variable options are no longer being passed in as part of the options hash to defined blocks and partials
|
93
|
+
* :template_folder and :variable options are no longer being passed in as part of the options hash to defined blocks and partials
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'bundler/gem_tasks'
|
|
4
4
|
# Default directory to look in is `/specs`
|
5
5
|
# Run with `rake spec`
|
6
6
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
-
task.rspec_opts = ['--color', '--format', '
|
7
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :default => :spec
|
10
|
+
task :default => :spec
|
data/lib/blocks.rb
CHANGED
@@ -14,6 +14,7 @@ module Blocks
|
|
14
14
|
@@config.wrap_before_and_after_blocks = false
|
15
15
|
@@config.use_partials = false
|
16
16
|
@@config.partials_folder = "blocks"
|
17
|
+
@@config.skip_applies_to_surrounding_blocks = false
|
17
18
|
|
18
19
|
# Default way to setup Blocks
|
19
20
|
def self.setup
|
@@ -21,5 +22,5 @@ module Blocks
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
ActionView::Base.send :include, Blocks::ViewAdditions
|
25
|
-
ActionController::Base.send :include, Blocks::ControllerAdditions
|
25
|
+
ActionView::Base.send :include, Blocks::ViewAdditions
|
26
|
+
ActionController::Base.send :include, Blocks::ControllerAdditions
|
data/lib/blocks/base.rb
CHANGED
@@ -16,6 +16,9 @@ module Blocks
|
|
16
16
|
# These are the options that are passed into the initalize method
|
17
17
|
attr_accessor :global_options
|
18
18
|
|
19
|
+
# Hash of block names that have been explicitely skipped
|
20
|
+
attr_accessor :skipped_blocks
|
21
|
+
|
19
22
|
# Checks if a particular block has been defined within the current block scope.
|
20
23
|
# <%= blocks.defined? :some_block_name %>
|
21
24
|
# Options:
|
@@ -90,6 +93,7 @@ module Blocks
|
|
90
93
|
# The name of the block to skip rendering for
|
91
94
|
def skip(name)
|
92
95
|
blocks[name] = nil
|
96
|
+
skipped_blocks[name] = true
|
93
97
|
self.define_block_container(name) do
|
94
98
|
end
|
95
99
|
nil
|
@@ -147,6 +151,10 @@ module Blocks
|
|
147
151
|
def render(name_or_container, *args, &block)
|
148
152
|
options = args.extract_options!
|
149
153
|
collection = options.delete(:collection)
|
154
|
+
name = extract_block_name name_or_container
|
155
|
+
if skipped_blocks[name] && global_options.skip_applies_to_surrounding_blocks
|
156
|
+
return
|
157
|
+
end
|
150
158
|
|
151
159
|
buffer = ActiveSupport::SafeBuffer.new
|
152
160
|
|
@@ -415,6 +423,7 @@ module Blocks
|
|
415
423
|
def initialize(view, options={})
|
416
424
|
self.view = view
|
417
425
|
self.global_options = Blocks.config.merge(options)
|
426
|
+
self.skipped_blocks = HashWithIndifferentAccess.new
|
418
427
|
self.blocks = HashWithIndifferentAccess.new
|
419
428
|
self.anonymous_block_number = 0
|
420
429
|
end
|
@@ -428,7 +437,7 @@ module Blocks
|
|
428
437
|
end
|
429
438
|
|
430
439
|
def render_block_with_around_blocks(name_or_container, *args, &block)
|
431
|
-
name =
|
440
|
+
name = extract_block_name name_or_container
|
432
441
|
around_name = "around_#{name}"
|
433
442
|
|
434
443
|
around_blocks = blocks[around_name].present? ? blocks[around_name].clone : []
|
@@ -448,13 +457,7 @@ module Blocks
|
|
448
457
|
def render_block(name_or_container, *args, &block)
|
449
458
|
buffer = ActiveSupport::SafeBuffer.new
|
450
459
|
|
451
|
-
|
452
|
-
name = name_or_container.name.to_sym
|
453
|
-
block_render_options = name_or_container.options
|
454
|
-
else
|
455
|
-
name = name_or_container.to_sym
|
456
|
-
block_render_options = {}
|
457
|
-
end
|
460
|
+
name, block_render_options = extract_block_name_and_options(name_or_container)
|
458
461
|
|
459
462
|
block_definition_options = {}
|
460
463
|
if blocks[name]
|
@@ -472,10 +475,10 @@ module Blocks
|
|
472
475
|
begin
|
473
476
|
begin
|
474
477
|
buffer << view.render("#{name.to_s}", options)
|
475
|
-
rescue ActionView::MissingTemplate
|
478
|
+
rescue ActionView::MissingTemplate, ArgumentError
|
476
479
|
buffer << view.render("#{options[:partials_folder]}/#{name.to_s}", options)
|
477
480
|
end
|
478
|
-
rescue ActionView::MissingTemplate
|
481
|
+
rescue ActionView::MissingTemplate, ArgumentError
|
479
482
|
args.push(global_options.merge(options))
|
480
483
|
buffer << view.capture(*(args[0, block.arity]), &block) if block_given?
|
481
484
|
end
|
@@ -560,5 +563,17 @@ module Blocks
|
|
560
563
|
blocks[block_container.name] = block_container if blocks[block_container.name].nil? && block_given?
|
561
564
|
block_container
|
562
565
|
end
|
566
|
+
|
567
|
+
def extract_block_name(name_or_container)
|
568
|
+
extract_block_name_and_options(name_or_container).first
|
569
|
+
end
|
570
|
+
|
571
|
+
def extract_block_name_and_options(name_or_container)
|
572
|
+
if name_or_container.is_a?(Blocks::Container)
|
573
|
+
[name_or_container.name, name_or_container.options]
|
574
|
+
else
|
575
|
+
[name_or_container, {}]
|
576
|
+
end
|
577
|
+
end
|
563
578
|
end
|
564
579
|
end
|
data/lib/blocks/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Blocks
|
2
|
-
VERSION = "2.
|
3
|
-
end
|
2
|
+
VERSION = "2.7.0"
|
3
|
+
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module Blocks
|
2
2
|
module ViewAdditions
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@blocks
|
9
|
-
end
|
3
|
+
def blocks
|
4
|
+
return @blocks if @blocks
|
5
|
+
@blocks = Blocks::Base.new(self)
|
6
|
+
@blocks.blocks.merge! @controller_blocks.blocks if @controller_blocks
|
7
|
+
@blocks
|
10
8
|
end
|
11
9
|
end
|
12
|
-
end
|
10
|
+
end
|
data/spec/blocks/base_spec.rb
CHANGED
@@ -15,32 +15,32 @@ describe Blocks::Base do
|
|
15
15
|
@builder.expects(:render_before_blocks).at_least_once
|
16
16
|
@builder.expects(:render_after_blocks).at_least_once
|
17
17
|
# @view.expects(:capture).with(:value1 => 1, :value2 => 2).never
|
18
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'shared', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
19
|
-
@view.expects(:render).with("shared/some_block", 'partials_folder' => 'shared', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).once
|
18
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'shared', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
19
|
+
@view.expects(:render).with("shared/some_block", 'partials_folder' => 'shared', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).once
|
20
20
|
@builder.render :some_block, :value1 => 1, :value2 => 2
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#defined?" do
|
24
24
|
it "should be able to determine if a block by a specific name is already defined" do
|
25
|
-
@builder.defined?(:test_block).should
|
25
|
+
@builder.defined?(:test_block).should be false
|
26
26
|
@builder.define :test_block do end
|
27
|
-
@builder.defined?(:test_block).should
|
27
|
+
@builder.defined?(:test_block).should be true
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should not care whether the block name was defined with a string or a symbol" do
|
31
|
-
@builder.defined?(:test_block).should
|
31
|
+
@builder.defined?(:test_block).should be false
|
32
32
|
@builder.define "test_block" do end
|
33
|
-
@builder.defined?(:test_block).should
|
33
|
+
@builder.defined?(:test_block).should be true
|
34
34
|
|
35
|
-
@builder.defined?(:test_block2).should
|
35
|
+
@builder.defined?(:test_block2).should be false
|
36
36
|
@builder.define :test_block2 do end
|
37
|
-
@builder.defined?(:test_block2).should
|
37
|
+
@builder.defined?(:test_block2).should be true
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should not care whether the defined? method is passed a string or a symbol" do
|
41
|
-
@builder.defined?("test_block").should
|
41
|
+
@builder.defined?("test_block").should be false
|
42
42
|
@builder.define :test_block do end
|
43
|
-
@builder.defined?("test_block").should
|
43
|
+
@builder.defined?("test_block").should be true
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -299,7 +299,7 @@ describe Blocks::Base do
|
|
299
299
|
it "should automatically pass in an options hash to a defined block that takes one paramter when that block is rendered" do
|
300
300
|
block = Proc.new {|options| print_hash(options) }
|
301
301
|
@builder.define :some_block, &block
|
302
|
-
@builder.render(:some_block).should eql print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", )
|
302
|
+
@builder.render(:some_block).should eql print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :skip_applies_to_surrounding_blocks => true)
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should be able to render a defined block by its name and pass in runtime arguments as a hash" do
|
@@ -307,7 +307,7 @@ describe Blocks::Base do
|
|
307
307
|
print_hash(options)
|
308
308
|
end
|
309
309
|
@builder.define :some_block, &block
|
310
|
-
@builder.render(:some_block, :param1 => 1, :param2 => "value2").should eql print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :param1 => 1, :param2 => "value2")
|
310
|
+
@builder.render(:some_block, :param1 => 1, :param2 => "value2").should eql print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :skip_applies_to_surrounding_blocks => true, :param1 => 1, :param2 => "value2")
|
311
311
|
end
|
312
312
|
|
313
313
|
it "should be able to render a defined block by its name and pass in runtime arguments one by one" do
|
@@ -315,7 +315,7 @@ describe Blocks::Base do
|
|
315
315
|
"first_param: #{first_param}, second_param: #{second_param}, #{print_hash options}"
|
316
316
|
end
|
317
317
|
@builder.define :some_block, &block
|
318
|
-
@builder.render(:some_block, 3, 4, :param1 => 1, :param2 => "value2").should eql("first_param: 3, second_param: 4, #{print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :param1 => 1, :param2 => "value2")}")
|
318
|
+
@builder.render(:some_block, 3, 4, :param1 => 1, :param2 => "value2").should eql("first_param: 3, second_param: 4, #{print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :skip_applies_to_surrounding_blocks => true, :param1 => 1, :param2 => "value2")}")
|
319
319
|
end
|
320
320
|
|
321
321
|
it "should match up the number of arguments to a defined block with the parameters passed when a block is rendered" do
|
@@ -331,7 +331,7 @@ describe Blocks::Base do
|
|
331
331
|
"first_param: #{first_param}, second_param: #{second_param}, #{print_hash options}"
|
332
332
|
end
|
333
333
|
@builder.replace :some_block, &block
|
334
|
-
@builder.render(:some_block, 3, 4, :param1 => 1, :param2 => "value2").should eql("first_param: 3, second_param: 4, #{print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :param1 => 1, :param2 => "value2")}")
|
334
|
+
@builder.render(:some_block, 3, 4, :param1 => 1, :param2 => "value2").should eql("first_param: 3, second_param: 4, #{print_hash(:wrap_before_and_after_blocks => false, :use_partials => false, :partials_folder => "blocks", :skip_applies_to_surrounding_blocks => true, :param1 => 1, :param2 => "value2")}")
|
335
335
|
end
|
336
336
|
|
337
337
|
it "should not render anything if using a block that has been defined" do
|
@@ -339,8 +339,8 @@ describe Blocks::Base do
|
|
339
339
|
config.use_partials = true
|
340
340
|
end
|
341
341
|
@builder = Blocks::Base.new(@view)
|
342
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
343
|
-
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
342
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
343
|
+
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
344
344
|
@builder.render :some_block
|
345
345
|
end
|
346
346
|
|
@@ -357,8 +357,8 @@ describe Blocks::Base do
|
|
357
357
|
config.use_partials = true
|
358
358
|
end
|
359
359
|
@builder = Blocks::Base.new(@view)
|
360
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).once
|
361
|
-
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).never
|
360
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).once
|
361
|
+
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).never
|
362
362
|
@builder.render :some_block, :value1 => 1, :value2 => 2
|
363
363
|
end
|
364
364
|
|
@@ -367,8 +367,8 @@ describe Blocks::Base do
|
|
367
367
|
config.use_partials = true
|
368
368
|
end
|
369
369
|
@builder = Blocks::Base.new(@view)
|
370
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
371
|
-
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).once
|
370
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
371
|
+
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).once
|
372
372
|
@builder.render :some_block, :value1 => 1, :value2 => 2
|
373
373
|
end
|
374
374
|
|
@@ -381,8 +381,8 @@ describe Blocks::Base do
|
|
381
381
|
config.use_partials = true
|
382
382
|
end
|
383
383
|
@builder = Blocks::Base.new(@view)
|
384
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
385
|
-
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
384
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
385
|
+
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => true, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).raises(ActionView::MissingTemplate.new([],[],[],[],[]))
|
386
386
|
@builder.render :some_block, :value1 => 1, :value2 => 2, &block
|
387
387
|
end
|
388
388
|
|
@@ -391,8 +391,8 @@ describe Blocks::Base do
|
|
391
391
|
options[:value1].should eql 1
|
392
392
|
options[:value2].should eql 2
|
393
393
|
end
|
394
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'value1' => 1, 'value2' => 2).never
|
395
|
-
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'value1' => 1, 'value2' => 2).never
|
394
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).never
|
395
|
+
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).never
|
396
396
|
@builder.render :some_block, :value1 => 1, :value2 => 2, &block
|
397
397
|
end
|
398
398
|
|
@@ -405,8 +405,8 @@ describe Blocks::Base do
|
|
405
405
|
options[:value1].should eql 1
|
406
406
|
options[:value2].should eql 2
|
407
407
|
end
|
408
|
-
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'value1' => 1, 'value2' => 2).never
|
409
|
-
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'value1' => 1, 'value2' => 2).never
|
408
|
+
@view.expects(:render).with("some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).never
|
409
|
+
@view.expects(:render).with("blocks/some_block", 'partials_folder' => 'blocks', 'wrap_before_and_after_blocks' => false, 'use_partials' => false, 'skip_applies_to_surrounding_blocks' => true, 'value1' => 1, 'value2' => 2).never
|
410
410
|
@builder.render :some_block, :value1 => 1, :value2 => 2, &block
|
411
411
|
end
|
412
412
|
|
@@ -591,14 +591,14 @@ describe Blocks::Base do
|
|
591
591
|
|
592
592
|
it "should be able to nest multiple around blocks with the last defined around block on the outside" do
|
593
593
|
my_block = Proc.new { "test" }
|
594
|
-
around_block1 = Proc.new { |content_block|
|
595
|
-
around_block2 = Proc.new { |content_block|
|
596
|
-
around_block3 = Proc.new { |content_block|
|
594
|
+
around_block1 = Proc.new { |content_block| @view.content_tag :h1, content_block.call }
|
595
|
+
around_block2 = Proc.new { |content_block| @view.content_tag :span, content_block.call, :style => "font-size: 100px" }
|
596
|
+
around_block3 = Proc.new { |content_block| @view.content_tag :span, content_block.call, :style => "style='color:red" }
|
597
597
|
@builder.define(:my_block, &my_block)
|
598
598
|
@builder.around(:my_block, &around_block1)
|
599
599
|
@builder.around(:my_block, &around_block2)
|
600
600
|
@builder.around(:my_block, &around_block3)
|
601
|
-
@builder.render(:my_block).should eql(
|
601
|
+
@builder.render(:my_block).should eql(%%<h1><span style="font-size: 100px"><span style="style='color:red">test</span></span></h1>%)
|
602
602
|
end
|
603
603
|
end
|
604
604
|
|
@@ -632,4 +632,4 @@ describe Blocks::Base do
|
|
632
632
|
@builder.render :my_after_block, :param1 => "top level"
|
633
633
|
end
|
634
634
|
end
|
635
|
-
end
|
635
|
+
end
|
@@ -4,7 +4,7 @@ describe Blocks::ViewAdditions do
|
|
4
4
|
before(:each) do
|
5
5
|
@view_class = Class.new
|
6
6
|
@view = @view_class.new
|
7
|
-
@view_class.send(:include, Blocks::ViewAdditions
|
7
|
+
@view_class.send(:include, Blocks::ViewAdditions)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#blocks" do
|
@@ -19,4 +19,4 @@ describe Blocks::ViewAdditions do
|
|
19
19
|
@view.blocks.should eql "something"
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hunter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.4.2
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Blocks goes beyond blocks and partials
|
@@ -166,3 +166,4 @@ test_files:
|
|
166
166
|
- spec/blocks/blocks_spec.rb
|
167
167
|
- spec/blocks/view_additions_spec.rb
|
168
168
|
- spec/spec_helper.rb
|
169
|
+
has_rdoc:
|