Module: Jurou::ViewHelpers
- Defined in:
- lib/jurou/view_helpers.rb
Instance Method Summary collapse
- #jr_attribute(attribute, model = nil) ⇒ Object (also: #jr_attr)
- #jr_collection(attribute, model = nil) ⇒ Object
- #jr_content_for_page_title(text = nil, divider = "|") ⇒ Object (also: #jr_title)
- #jr_page_title(app_title = "jurou.app_title", divider = "|") ⇒ Object
- #jr_simple_title(controller = nil, action = nil) ⇒ Object
- #jr_table_row(attribute, value = nil, model = nil) ⇒ Object (also: #jr_row)
- #jr_table_row_translate_value(attribute, value = nil, model = nil) ⇒ Object (also: #jr_row_val)
- #jr_value(attribute, value = nil, model = nil) ⇒ Object
Instance Method Details
#jr_attribute(attribute, model = nil) ⇒ Object Also known as: jr_attr
49 50 51 52 |
# File 'lib/jurou/view_helpers.rb', line 49 def jr_attribute(attribute, model = nil) jr_init_model(model) I18n.t("activerecord.attributes.#{@_model}.#{attribute}") end |
#jr_collection(attribute, model = nil) ⇒ Object
26 27 28 29 |
# File 'lib/jurou/view_helpers.rb', line 26 def jr_collection(attribute, model = nil) jr_init_model(model) I18n.t("jurou.#{@_model}.#{attribute}").invert end |
#jr_content_for_page_title(text = nil, divider = "|") ⇒ Object Also known as: jr_title
8 9 10 11 |
# File 'lib/jurou/view_helpers.rb', line 8 def jr_content_for_page_title(text = nil, divider = "|") @jr_title = "#{text} #{divider} " if text nil end |
#jr_page_title(app_title = "jurou.app_title", divider = "|") ⇒ Object
4 5 6 |
# File 'lib/jurou/view_helpers.rb', line 4 def jr_page_title(app_title = "jurou.app_title", divider = "|") "#{@jr_title}#{jr_page_title_by_controller_action(app_title, divider)}" end |
#jr_simple_title(controller = nil, action = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/jurou/view_helpers.rb', line 14 def jr_simple_title(controller = nil, action = nil) unless action if controller action = :_label else controller = controller_path action = action_name end end I18n.t(jr_page_title_translation_key(controller, action)) end |
#jr_table_row(attribute, value = nil, model = nil) ⇒ Object Also known as: jr_row
31 32 33 34 35 36 37 |
# File 'lib/jurou/view_helpers.rb', line 31 def jr_table_row(attribute, value = nil, model = nil) jr_init_model(model) content_tag :tr do concat content_tag :th, jr_attribute(attribute, @_model) concat content_tag :td, jr_init_value(attribute, value) end end |
#jr_table_row_translate_value(attribute, value = nil, model = nil) ⇒ Object Also known as: jr_row_val
40 41 42 43 44 45 46 |
# File 'lib/jurou/view_helpers.rb', line 40 def jr_table_row_translate_value(attribute, value = nil, model = nil) jr_init_model(model) content_tag :tr do concat content_tag :th, jr_attribute(attribute, @_model) concat content_tag :td, jr_value(attribute, value, @_model) end end |
#jr_value(attribute, value = nil, model = nil) ⇒ Object
55 56 57 58 |
# File 'lib/jurou/view_helpers.rb', line 55 def jr_value(attribute, value = nil, model = nil) jr_init_model(model) I18n.t("jurou.#{@_model}.#{attribute}.#{jr_init_value(attribute, value)}") end |