module SimpleForm::Tags::CollectionExtensions

Private Instance Methods

render_collection() { |item, value, text, default_html_options| ... } click to toggle source
# File lib/simple_form/tags.rb, line 6
def render_collection
  item_wrapper_tag   = @options.fetch(:item_wrapper_tag, :span)
  item_wrapper_class = @options[:item_wrapper_class]

  @collection.map do |item|
    value = value_for_collection(item, @value_method)
    text  = value_for_collection(item, @text_method)
    default_html_options = default_html_options_for_collection(item, value)

    rendered_item = yield item, value, text, default_html_options

    item_wrapper_tag ? @template_object.content_tag(item_wrapper_tag, rendered_item, class: item_wrapper_class) : rendered_item
  end.join.html_safe
end
wrap_rendered_collection(collection) click to toggle source
# File lib/simple_form/tags.rb, line 21
def wrap_rendered_collection(collection)
  wrapper_tag = @options[:collection_wrapper_tag]

  if wrapper_tag
    wrapper_class = @options[:collection_wrapper_class]
    @template_object.content_tag(wrapper_tag, collection, class: wrapper_class)
  else
    collection
  end
end