Module: Jetpack::Helper
- Defined in:
- lib/jetpack/helper.rb
Instance Method Summary collapse
-
#flash_messages ⇒ Object
Outputs a standard flash message.
-
#nav_link_to(text, path) ⇒ Object
Creates a nav link, ie.
-
#title(page_title) ⇒ Object
Creates a smart title helper, appending [DEV] when you’re in dev mode.
-
#view_name ⇒ Object
Creates a view name for CSS namespacing.
-
#viewing?(string) ⇒ Boolean
Checks whether the user is looking at a particular view.
Instance Method Details
#flash_messages ⇒ Object
Outputs a standard flash message.
25 26 27 28 29 30 31 32 |
# File 'lib/jetpack/helper.rb', line 25 def str = "" flash.each do |type, msg| type == :alert ? persist = true : persist = false str += content_tag :div, msg, :class => ['alert-message', type], :data => { :persist => persist } end str.html_safe end |
#nav_link_to(text, path) ⇒ Object
Creates a nav link, ie. one that links to nothing (“#”) if it is the current page and in that case the link has the class “current”
18 19 20 21 22 |
# File 'lib/jetpack/helper.rb', line 18 def nav_link_to(text, path) link_to_unless_current text, path do link_to text, '#', :class => 'current' end end |
#title(page_title) ⇒ Object
Creates a smart title helper, appending [DEV] when you’re in dev mode.
35 36 37 38 |
# File 'lib/jetpack/helper.rb', line 35 def title(page_title) mode = "[DEV] " unless ::Rails.env.production? content_for(:title) { mode.to_s + page_title + " | " } end |
#view_name ⇒ Object
Creates a view name for CSS namespacing.
6 7 8 |
# File 'lib/jetpack/helper.rb', line 6 def view_name [controller.controller_name,controller.action_name,params[:id]].compact.join(' ') end |
#viewing?(string) ⇒ Boolean
Checks whether the user is looking at a particular view. Helpful for cases like a unique home page design element: - if viewing? ‘home’
12 13 14 |
# File 'lib/jetpack/helper.rb', line 12 def viewing?(string) view_name.include?(string) end |