Module: Attrtastic::SemanticAttributesHelper
- Defined in:
- lib/attrtastic/semantic_attributes_helper.rb
Overview
Helper which should be included in ActionView. Adds #semantic_attributes_for method, which helps printing attributes for given record, similar to formtastic’s sematnic_form_for
Instance Method Summary (collapse)
-
- (Object) semantic_attributes_for(record, options = {}) {|attr| ... }
Creates attributes for given object.
Instance Method Details
- (Object) semantic_attributes_for(record, options = {}) {|attr| ... }
Creates attributes for given object
@param[ActiveRecord] record AR instance record for which to display attributes @param[Hash] options Opions
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/attrtastic/semantic_attributes_helper.rb', line 41 def semantic_attributes_for(record, = {}, &block) [:html] ||= {} html_class = [ "attrtastic", record.class.to_s.underscore, [:html][:class] ].compact.join(" ") output = tag(:div, { :class => html_class}, true) if block_given? output << capture(SemanticAttributesBuilder.new(record, self), &block) end output.safe_concat("</div>") end |