module Jurou::ViewHelpers
Public Instance Methods
jr_attribute(attribute, model = nil)
click to toggle source
# 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
Also aliased as: jr_attr
jr_collection(attribute, model = nil)
click to toggle source
# 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 = "|")
click to toggle source
# 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
Also aliased as: jr_title
jr_page_title(app_title = "jurou.app_title", divider = "|")
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Also aliased as: jr_row
jr_table_row_translate_value(attribute, value = nil, model = nil)
click to toggle source
# 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
Also aliased as: jr_row_val
jr_value(attribute, value = nil, model = nil)
click to toggle source
# 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
Private Instance Methods
jr_init_model(model)
click to toggle source
# File lib/jurou/view_helpers.rb, line 62 def jr_init_model(model) @_model = if model model elsif params[:id] and current_object current_object.model_name.param_key else controller_name.singularize end end
jr_init_value(attribute, value)
click to toggle source
# File lib/jurou/view_helpers.rb, line 73 def jr_init_value(attribute, value) value || current_object.send(attribute) end
jr_page_title_by_controller_action(app_title, divider)
click to toggle source
# File lib/jurou/view_helpers.rb, line 77 def jr_page_title_by_controller_action(app_title, divider) "#{t(jr_page_title_translation_key, raise: true)} #{divider} #{t(app_title)}" rescue t(app_title) end
jr_page_title_translation_key(controller = controller_path, action = action_name)
click to toggle source
# File lib/jurou/view_helpers.rb, line 83 def jr_page_title_translation_key(controller = controller_path, action = action_name) :"jurou.page_titles.#{controller}.#{action}" end