Method: CommonLib::ActionViewExtension::Base#_wrapped_spans
- Defined in:
- lib/common_lib/action_view_extension/base.rb
#_wrapped_spans(object_name, method, options = {}) ⇒ Object
This is NOT a form field
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/common_lib/action_view_extension/base.rb', line 57 def _wrapped_spans(object_name,method,={}) object = instance_variable_get("@#{object_name}") # s = "<span class='label'>#{options[:label_text]||method}</span>\n" # could also "object.class.human_attribute_name method" ? # s = "<span class='label'>#{options[:label_text]||I18n.translate( # "#{object.class.to_s.underscore}.#{method}", # :scope => "activerecord.attributes", # :default => method.to_s)}</span>\n" # if method is a symbol, tries to translate it too. # # label = if options[:label_text].present? # options[:label_text] # else # l = ( I18n.translate("#{object.class.to_s.underscore}.#{method}", # :scope => "activerecord.attributes", :raise => true ) rescue false ) || # method.to_s # l.send( :humanize or :titleize or :gsub('_', ' ') or ...... # end # # titleize - capitalizes all words # humanize - capitalizes only the first word ( same as other rails helpers, but I don't like ) # # s = "<span class='label'>#{[:label_text] || ( I18n.translate("#{object.class.to_s.underscore}.#{method}", :scope => "activerecord.attributes", :raise => true ) rescue false ) || method.to_s.humanize }</span>\n" # if method is a symbol, tries to translate it too. value = if [:value] [:value] else # moved to top # object = instance_variable_get("@#{object_name}") value = object.send(method) value = (value.to_s.blank?)?' ':value end s << "<span class='value'>#{value}</span>" s << (( .has_key?(:post_text) ) ? "<span class='post_text'>#{[:post_text]}</span>" : "") s.html_safe end |