Module: Trejo::ViewHelpers
- Defined in:
- lib/trejo/view_helpers.rb
Instance Method Summary collapse
- #body_class ⇒ Object
- #body_id ⇒ Object
- #copyright_notice(company_name = nil) ⇒ Object
- #merge_classes(*classes) ⇒ Object
- #nav_item(name, url, options = {}) ⇒ Object
- #page_class(value) ⇒ Object
- #page_id(value) ⇒ Object
- #site_title ⇒ Object
- #title(page_title = nil) ⇒ Object
Instance Method Details
#body_class ⇒ Object
36 37 38 |
# File 'lib/trejo/view_helpers.rb', line 36 def body_class content_for?(:page_class) ? content_for(:page_class) : nil end |
#body_id ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/trejo/view_helpers.rb', line 28 def body_id if content_for?(:page_id) content_for(:page_id) else "#{controller.controller_name}-#{controller.action_name}-page".dasherize end end |
#copyright_notice(company_name = nil) ⇒ Object
48 49 50 |
# File 'lib/trejo/view_helpers.rb', line 48 def copyright_notice company_name = nil "\u00A9 #{Date.current.year} #{company_name.presence || Trejo.configuration.company_name}, All Rights Reserved" end |
#merge_classes(*classes) ⇒ Object
16 17 18 19 20 |
# File 'lib/trejo/view_helpers.rb', line 16 def merge_classes(*classes) classes.flatten .reject(&:blank?).map(&:split) .flatten.uniq.join ' ' end |
#nav_item(name, url, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/trejo/view_helpers.rb', line 3 def nav_item name, url, ={} current_path = request.fullpath selected = if [:selected] current_path =~ [:selected] else current_path =~ /^#{Regexp.escape(url)}.*(?:\?.*)?/ end link_class = [:class] || 'active' if selected link_to name, url, class: link_class end |
#page_class(value) ⇒ Object
44 45 46 |
# File 'lib/trejo/view_helpers.rb', line 44 def page_class value content_for(:page_class) { value } end |
#page_id(value) ⇒ Object
40 41 42 |
# File 'lib/trejo/view_helpers.rb', line 40 def page_id value content_for(:page_id) { value } end |
#site_title ⇒ Object
52 53 54 |
# File 'lib/trejo/view_helpers.rb', line 52 def site_title Trejo.configuration.site_title end |
#title(page_title = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/trejo/view_helpers.rb', line 22 def title page_title = nil content_for(:title) do [page_title, Trejo.configuration.site_title].compact.join(' | ') end end |