Module: RailsI18nManager::ApplicationHelper
- Defined in:
- app/helpers/rails_i18n_manager/application_helper.rb
Constant Summary collapse
- ASSET_VERSION =
`git show -s --format=%ci`.parameterize.freeze
Instance Method Summary collapse
- #breadcrumb_item(title, url = nil) ⇒ Object
- #custom_asset_path(path) ⇒ Object
- #custom_fields_for(*args, **options, &block) ⇒ Object
- #custom_form_for(*args, **options, &block) ⇒ Object
- #nav_link(name, url, html_options = {}, &block) ⇒ Object
- #sort_link(attr_name, label = nil) ⇒ Object
Instance Method Details
#breadcrumb_item(title, url = nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/helpers/rails_i18n_manager/application_helper.rb', line 25 def (title, url=nil) if url.nil? %Q(<span class="breadcrumb-item">#{title}</span>).html_safe else %Q(<span class="breadcrumb-item"><a href="#{url}">#{title}</a></span>).html_safe end end |
#custom_asset_path(path) ⇒ Object
21 22 23 |
# File 'app/helpers/rails_i18n_manager/application_helper.rb', line 21 def custom_asset_path(path) "#{path}?v=#{Rails.env.development? ? Time.now.to_i : ASSET_VERSION}" end |
#custom_fields_for(*args, **options, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/helpers/rails_i18n_manager/application_helper.rb', line 12 def custom_fields_for(*args, **, &block) [:builder] = CustomFormBuilder if .has_key?(:defaults) @_custom_form_for_defaults = .delete(:defaults) end fields_for(*args, , &block) end |
#custom_form_for(*args, **options, &block) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/rails_i18n_manager/application_helper.rb', line 4 def custom_form_for(*args, **, &block) [:builder] = CustomFormBuilder if .has_key?(:defaults) @_custom_form_for_defaults = .delete(:defaults) end form_for(*args, , &block) end |
#nav_link(name, url, html_options = {}, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/helpers/rails_i18n_manager/application_helper.rb', line 43 def nav_link(name, url, ={}, &block) url = url_for(url) if .has_key?(:active) active = .delete(:active) elsif url == (url.include?("?") ? request.fullpath : request.path) active = true end [:class] ||= "" [:class] += " nav-link" if active [:class] += " active" end [:class].strip! content_tag(:li, class: "nav-item #{'active' if active}".strip) do link_to(name, url, ) + ( if block_given? content_tag(:ul) do capture(&block) end end ) end end |
#sort_link(attr_name, label = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/rails_i18n_manager/application_helper.rb', line 33 def sort_link(attr_name, label=nil) if label.blank? label = attr_name.to_s.titleize end direction = params[:direction].present? && params[:direction].casecmp?("asc") ? 'desc' : 'asc' link_to label, params.to_unsafe_h.merge(sort: attr_name, direction: direction) end |