blocks 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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:
@@ -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.0
1
+ 2.5.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "blocks"
8
- s.version = "2.5.0"
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-15"
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 = [
@@ -14,8 +14,8 @@ module Blocks
14
14
  mattr_accessor :use_partials
15
15
  @@use_partials = false
16
16
 
17
- mattr_accessor :wrap_with_surrounds_before_and_after_blocks
18
- @@wrap_with_surrounds_before_and_after_blocks = false
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)
@@ -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 :wrap_with_surrounds_before_and_after_blocks
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 a block, which might be particularly useful when rendering a collection of blocks,
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 attributes to be applied to the HTML content tag, such as styling or special properties. Please note, any Procs passed
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 wrap_with_surrounds_before_and_after_blocks
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
- # [:surrounding_tag]
234
- # The content tag to render around a block, which might be particularly useful when rendering a collection of blocks,
235
- # such as for a list or table
236
- # [:surrounding_tag_html]
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
- # [:surrounding_tag]
283
- # The content tag to render around a block, which might be particularly useful when rendering a collection of blocks,
284
- # such as for a list or table
285
- # [:surrounding_tag_html]
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.wrap_with_surrounds_before_and_after_blocks = options[:wrap_with_surrounds_before_and_after_blocks].nil? ? Blocks.wrap_with_surrounds_before_and_after_blocks : options.delete(:wrap_with_surrounds_before_and_after_blocks)
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)
@@ -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.wrap_with_surrounds_before_and_after_blocks = false
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, :wrap_with_surrounds_before_and_after_blocks => false)
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
 
@@ -13,7 +13,7 @@ RSpec.configure do |config|
13
13
 
14
14
  config.before :each do
15
15
  Blocks.template_folder = "blocks"
16
- Blocks.wrap_with_surrounds_before_and_after_blocks = true
16
+ Blocks.wrap_before_and_after_blocks = true
17
17
  Blocks.use_partials = false
18
18
  end
19
19
  end
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.0
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-15 00:00:00.000000000 Z
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: -2216410614422126676
137
+ hash: -1089807617590558203
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements: