lib/blocks/base.rb in blocks-2.5.0 vs lib/blocks/base.rb in blocks-2.5.1
- old
+ new
@@ -22,11 +22,11 @@
# Boolean variable for whether Blocks should attempt to render blocks as partials if a defined block cannot be found
attr_accessor :use_partials
# Boolean variable for whether Blocks should render before and after blocks inside or outside of a collections' elements' wrap_with tags
- attr_accessor :wrap_with_surrounds_before_and_after_blocks
+ attr_accessor :wrap_before_and_after_blocks
# Checks if a particular block has been defined within the current block scope.
# <%= blocks.defined? :some_block_name %>
# Options:
# [+name+]
@@ -141,15 +141,13 @@
# [:collection]
# The collection of elements to render blocks for
# [:as]
# The variable name to assign the current element in the collection being rendered over
# [:wrap_with]
- # The content tag to render around a block, which might be particularly useful when rendering a collection of blocks,
- # such as for a list or table
+ # The content tag to render around this block (For example: :wrap_with => {:tag => TAG_TYPE, :class => "my-class", :style => "border: 1px solid black"})
# [:wrap_each]
- # The attributes to be applied to the HTML content tag, such as styling or special properties. Please note, any Procs passed
- # in will automatically be evaluated (For example: :class => lambda { cycle("even", "odd") })
+ # The content tag to render around each item in a collection (For example: :wrap_each { :class => lambda { cycle("even", "odd") }})
# [:use_partials]
# Overrides the globally defined use_partials and tells Blocks to render partials in trying to render a block
# [:skip_partials]
# Overrides the globally defined use_partials and tells Blocks to not render any partials in trying to render a block
# [+block+]
@@ -184,11 +182,11 @@
buffer
end
else
args.push(options)
- if wrap_with_surrounds_before_and_after_blocks
+ if wrap_before_and_after_blocks
buffer << content_tag_with_block(wrap_with[:tag], wrap_with.except(:tag), *args) do
temp_buffer = ActiveSupport::SafeBuffer.new
temp_buffer << render_before_blocks(name_or_container, *args)
temp_buffer << render_block_with_around_blocks(name_or_container, *args, &block)
temp_buffer << render_after_blocks(name_or_container, *args)
@@ -228,16 +226,14 @@
# The last argument in the list can be a hash and can include the following special options:
# [:collection]
# The collection of elements to render blocks for
# [:as]
# The variable name to assign the current element in the collection being rendered over
- # [:surrounding_tag]
- # The content tag to render around a block, which might be particularly useful when rendering a collection of blocks,
- # such as for a list or table
- # [:surrounding_tag_html]
- # The attributes to be applied to the HTML content tag, such as styling or special properties. Please note, any Procs passed
- # in will automatically be evaluated (For example: :class => lambda { cycle("even", "odd") })
+ # [:wrap_with]
+ # The content tag to render around this block (For example: :wrap_with => {:tag => TAG_TYPE, :class => "my-class", :style => "border: 1px solid black"})
+ # [:wrap_each]
+ # The content tag to render around each item in a collection (For example: :wrap_each { :class => lambda { cycle("even", "odd") }})
# [+block+]
# The default block to render if no such block block that is to be rendered when "blocks.render" is called for this block.
def render_without_partials(name_or_container, *args, &block)
options = args.extract_options!
options[:skip_partials] = true
@@ -277,16 +273,14 @@
# The last argument in the list can be a hash and can include the following special options:
# [:collection]
# The collection of elements to render blocks for
# [:as]
# The variable name to assign the current element in the collection being rendered over
- # [:surrounding_tag]
- # The content tag to render around a block, which might be particularly useful when rendering a collection of blocks,
- # such as for a list or table
- # [:surrounding_tag_html]
- # The attributes to be applied to the HTML content tag, such as styling or special properties. Please note, any Procs passed
- # in will automatically be evaluated (For example: :class => lambda { cycle("even", "odd") })
+ # [:wrap_with]
+ # The content tag to render around this block (For example: :wrap_with => {:tag => TAG_TYPE, :class => "my-class", :style => "border: 1px solid black"})
+ # [:wrap_each]
+ # The content tag to render around each item in a collection (For example: :wrap_each { :class => lambda { cycle("even", "odd") }})
# [+block+]
# The default block to render if no such block block that is to be rendered when "blocks.render" is called for this block.
def render_with_partials(name_or_container, *args, &block)
options = args.extract_options!
options[:use_partials] = true
@@ -426,10 +420,10 @@
self.view = view
self.global_options = options
self.blocks = {}
self.anonymous_block_number = 0
self.use_partials = options[:use_partials].nil? ? Blocks.use_partials : options.delete(:use_partials)
- 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)
+ 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)
end
# Return a unique name for an anonymously defined block (i.e. a block that has not been given a name)
def anonymous_block_name
self.anonymous_block_number += 1