blocks 2.5.0 → 2.5.1
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.
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +2 -0
- data/VERSION +1 -1
- data/blocks.gemspec +2 -2
- data/lib/blocks.rb +2 -2
- data/lib/blocks/base.rb +13 -19
- data/spec/blocks/base_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
2.5.1 (October 17, 2013)
|
|
2
|
+
* Changed Blocks.wrap_with_surrounds_before_and_after_blocks to Blocks.wrap_before_and_after_blocks
|
|
3
|
+
|
|
1
4
|
2.5.0 (October 14, 2013)
|
|
2
5
|
* Added skip method as a shorthand for defining or replacing a block's definition so that nothing is output when the block is rendered
|
|
3
6
|
* Added ability to wrap each block in a collection with an element or render a block with an element, using syntax like:
|
data/README.rdoc
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
= Blocks
|
|
2
2
|
|
|
3
|
+
I AM CURRENTLY IN THE PROCESS OF WRITING THIS DOCUMENTATION OVER AGAIN SINCE A LOT HAS CHANGED SINCE THE DOCUMENTATION WAS ORIGINALLY WRITTEN.
|
|
4
|
+
|
|
3
5
|
How do you render your blocks of code?
|
|
4
6
|
|
|
5
7
|
The idea of this gem is simple (yet difficult to see the practical application for): blocks of code, regardless of code, whether they are a ruby block or a rails partial, are, or should be, completely interchangeable.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.5.
|
|
1
|
+
2.5.1
|
data/blocks.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "blocks"
|
|
8
|
-
s.version = "2.5.
|
|
8
|
+
s.version = "2.5.1"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Andrew Hunter"]
|
|
12
|
-
s.date = "2013-10-
|
|
12
|
+
s.date = "2013-10-17"
|
|
13
13
|
s.description = "Blocks goes beyond blocks and partials"
|
|
14
14
|
s.email = "hunterae@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/blocks.rb
CHANGED
|
@@ -14,8 +14,8 @@ module Blocks
|
|
|
14
14
|
mattr_accessor :use_partials
|
|
15
15
|
@@use_partials = false
|
|
16
16
|
|
|
17
|
-
mattr_accessor :
|
|
18
|
-
@@
|
|
17
|
+
mattr_accessor :wrap_before_and_after_blocks
|
|
18
|
+
@@wrap_before_and_after_blocks = false
|
|
19
19
|
|
|
20
20
|
# Shortcut for using the templating feature / rendering templates
|
|
21
21
|
def self.render_template(view, partial, options={}, &block)
|
data/lib/blocks/base.rb
CHANGED
|
@@ -24,7 +24,7 @@ module Blocks
|
|
|
24
24
|
attr_accessor :use_partials
|
|
25
25
|
|
|
26
26
|
# Boolean variable for whether Blocks should render before and after blocks inside or outside of a collections' elements' wrap_with tags
|
|
27
|
-
attr_accessor :
|
|
27
|
+
attr_accessor :wrap_before_and_after_blocks
|
|
28
28
|
|
|
29
29
|
# Checks if a particular block has been defined within the current block scope.
|
|
30
30
|
# <%= blocks.defined? :some_block_name %>
|
|
@@ -143,11 +143,9 @@ module Blocks
|
|
|
143
143
|
# [:as]
|
|
144
144
|
# The variable name to assign the current element in the collection being rendered over
|
|
145
145
|
# [:wrap_with]
|
|
146
|
-
# The content tag to render around
|
|
147
|
-
# such as for a list or table
|
|
146
|
+
# The content tag to render around this block (For example: :wrap_with => {:tag => TAG_TYPE, :class => "my-class", :style => "border: 1px solid black"})
|
|
148
147
|
# [:wrap_each]
|
|
149
|
-
# The
|
|
150
|
-
# in will automatically be evaluated (For example: :class => lambda { cycle("even", "odd") })
|
|
148
|
+
# The content tag to render around each item in a collection (For example: :wrap_each { :class => lambda { cycle("even", "odd") }})
|
|
151
149
|
# [:use_partials]
|
|
152
150
|
# Overrides the globally defined use_partials and tells Blocks to render partials in trying to render a block
|
|
153
151
|
# [:skip_partials]
|
|
@@ -186,7 +184,7 @@ module Blocks
|
|
|
186
184
|
else
|
|
187
185
|
args.push(options)
|
|
188
186
|
|
|
189
|
-
if
|
|
187
|
+
if wrap_before_and_after_blocks
|
|
190
188
|
buffer << content_tag_with_block(wrap_with[:tag], wrap_with.except(:tag), *args) do
|
|
191
189
|
temp_buffer = ActiveSupport::SafeBuffer.new
|
|
192
190
|
temp_buffer << render_before_blocks(name_or_container, *args)
|
|
@@ -230,12 +228,10 @@ module Blocks
|
|
|
230
228
|
# The collection of elements to render blocks for
|
|
231
229
|
# [:as]
|
|
232
230
|
# The variable name to assign the current element in the collection being rendered over
|
|
233
|
-
# [:
|
|
234
|
-
# The content tag to render around
|
|
235
|
-
#
|
|
236
|
-
#
|
|
237
|
-
# The attributes to be applied to the HTML content tag, such as styling or special properties. Please note, any Procs passed
|
|
238
|
-
# in will automatically be evaluated (For example: :class => lambda { cycle("even", "odd") })
|
|
231
|
+
# [:wrap_with]
|
|
232
|
+
# The content tag to render around this block (For example: :wrap_with => {:tag => TAG_TYPE, :class => "my-class", :style => "border: 1px solid black"})
|
|
233
|
+
# [:wrap_each]
|
|
234
|
+
# The content tag to render around each item in a collection (For example: :wrap_each { :class => lambda { cycle("even", "odd") }})
|
|
239
235
|
# [+block+]
|
|
240
236
|
# The default block to render if no such block block that is to be rendered when "blocks.render" is called for this block.
|
|
241
237
|
def render_without_partials(name_or_container, *args, &block)
|
|
@@ -279,12 +275,10 @@ module Blocks
|
|
|
279
275
|
# The collection of elements to render blocks for
|
|
280
276
|
# [:as]
|
|
281
277
|
# The variable name to assign the current element in the collection being rendered over
|
|
282
|
-
# [:
|
|
283
|
-
# The content tag to render around
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
# The attributes to be applied to the HTML content tag, such as styling or special properties. Please note, any Procs passed
|
|
287
|
-
# in will automatically be evaluated (For example: :class => lambda { cycle("even", "odd") })
|
|
278
|
+
# [:wrap_with]
|
|
279
|
+
# The content tag to render around this block (For example: :wrap_with => {:tag => TAG_TYPE, :class => "my-class", :style => "border: 1px solid black"})
|
|
280
|
+
# [:wrap_each]
|
|
281
|
+
# The content tag to render around each item in a collection (For example: :wrap_each { :class => lambda { cycle("even", "odd") }})
|
|
288
282
|
# [+block+]
|
|
289
283
|
# The default block to render if no such block block that is to be rendered when "blocks.render" is called for this block.
|
|
290
284
|
def render_with_partials(name_or_container, *args, &block)
|
|
@@ -428,7 +422,7 @@ module Blocks
|
|
|
428
422
|
self.blocks = {}
|
|
429
423
|
self.anonymous_block_number = 0
|
|
430
424
|
self.use_partials = options[:use_partials].nil? ? Blocks.use_partials : options.delete(:use_partials)
|
|
431
|
-
self.
|
|
425
|
+
self.wrap_before_and_after_blocks = options[:wrap_before_and_after_blocks].nil? ? Blocks.wrap_before_and_after_blocks : options.delete(:wrap_before_and_after_blocks)
|
|
432
426
|
end
|
|
433
427
|
|
|
434
428
|
# Return a unique name for an anonymously defined block (i.e. a block that has not been given a name)
|
data/spec/blocks/base_spec.rb
CHANGED
|
@@ -407,7 +407,7 @@ describe Blocks::Base do
|
|
|
407
407
|
end
|
|
408
408
|
|
|
409
409
|
it "should allow the global option to be set to render before and after blocks outside of surrounding elements" do
|
|
410
|
-
Blocks.
|
|
410
|
+
Blocks.wrap_before_and_after_blocks = false
|
|
411
411
|
@builder = Blocks::Base.new(@view)
|
|
412
412
|
before_block = Proc.new {|item, options| "before#{options[:some_block]} "}
|
|
413
413
|
@builder.before :some_block, &before_block
|
|
@@ -421,7 +421,7 @@ describe Blocks::Base do
|
|
|
421
421
|
end
|
|
422
422
|
|
|
423
423
|
it "should allow the option to be set to render before and after blocks outside of surrounding elements to be specified when Blocks is initialized" do
|
|
424
|
-
@builder = Blocks::Base.new(@view, :
|
|
424
|
+
@builder = Blocks::Base.new(@view, :wrap_before_and_after_blocks => false)
|
|
425
425
|
before_block = Proc.new {|item, options| "before#{options[:some_block]} "}
|
|
426
426
|
@builder.before :some_block, &before_block
|
|
427
427
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blocks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.
|
|
4
|
+
version: 2.5.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-10-
|
|
12
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
134
134
|
version: '0'
|
|
135
135
|
segments:
|
|
136
136
|
- 0
|
|
137
|
-
hash: -
|
|
137
|
+
hash: -1089807617590558203
|
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
none: false
|
|
140
140
|
requirements:
|