Module: Archangel::ApplicationHelper
- Defined in:
- app/helpers/archangel/application_helper.rb
Overview
Application helpers
Instance Method Summary collapse
-
#active_backend_menu_for(ctrlr) ⇒ Boolean
Check if active backend menu for a controller.
-
#frontend_resource_path(resource) ⇒ String
Frontend resource permalink.
-
#locale ⇒ String
Site locale.
-
#text_direction ⇒ String
Language direction (“ltr” or “rtl”).
Instance Method Details
#active_backend_menu_for(ctrlr) ⇒ Boolean
Check if active backend menu for a controller
Example
<%= active_backend_menu_for("users") %> #=> true
<%= active_backend_menu_for("pages") %> #=> false
64 65 66 |
# File 'app/helpers/archangel/application_helper.rb', line 64 def (ctrlr) params.fetch(:controller) == "archangel/backend/#{ctrlr}" end |
#frontend_resource_path(resource) ⇒ String
Frontend resource permalink.
Same as ‘frontend_page_path` except it prints out nested resources in a nice way.
Example
<%= frontend_resource_path('amazing/grace') %> #=> /amazing/grace
<%= frontend_resource_path(@page) %> #=> /amazing/grace
20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/archangel/application_helper.rb', line 20 def frontend_resource_path(resource) permalink_path = proc do |permalink| archangel.frontend_page_path(permalink).sub("%2F", "/") end return permalink_path.call(resource) unless resource.class == Page return archangel.frontend_root_path if resource.homepage? permalink_path.call(resource.permalink) end |
#locale ⇒ String
Site locale. Default ‘en`
Example
<%= locale %> #=> "en"
39 40 41 |
# File 'app/helpers/archangel/application_helper.rb', line 39 def locale current_site.locale || Archangel::LANGUAGE_DEFAULT end |
#text_direction ⇒ String
Language direction (“ltr” or “rtl”). Default ‘ltr`
Example
<%= text_direction %> #=> "ltr"
51 52 53 |
# File 'app/helpers/archangel/application_helper.rb', line 51 def text_direction Archangel.t("language.#{locale}.direction", default: "ltr") end |