Hey all,

Let's say we have this:

#view
= section "Contact" do
  - field_list :class => "contacts-view" do |v|
    = v.item "Contact Type", @contact.contact_type

#helper
  def section(*args, &block)
    label = String === args.first ? args.first : String ===
args.second ? args.second : nil
    klass = "#{klass} #{type ? type.to_s.dasherize :
nil}".strip.presence

    content = block ? capture(&block).html_safe : ""

    return "" if content.blank?

    content = content_tag(:legend, label) + content if label.present?
    content_tag :fieldset, content, :class => klass, :id =>
options.delete(:id)
  end

1) From what I read, passing a block into the rails capture method
will capture a block of html, so you can append/prepend other html to
it. But what does capture a block of html mean? Why wouldnt you be
able to append/prepend html to it otherwise?

2) I am not sure what the + operator is doing here:
content_tag(:legend, label) + content
Obviously, the content_for rails method wraps the string held in label
around legend tags. content local variable holds the html that was
created in the block passed into this iterator. But does the +
operator mean that we are prepending that html onto the legend tag
html?

thanks for response

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to