Module: LayoutHelper
- Defined in:
- lib/generators/leolay/templates/app/helpers/layout_helper.rb
Overview
These helper methods can be called in your template to set variables to be used in the layout This module should be included in all views globally, to do so you may need to add this line to your ApplicationController
helper :layout
Instance Method Summary collapse
- #javascript(*args) ⇒ Object
-
#page_entries_info(collection, singular_model_name, plural_model_name = nil) ⇒ Object
Show search informations.
- #secondary_navigation(*items) ⇒ Object
- #show_title? ⇒ Boolean
-
#style_image_tag(name, args = {}) ⇒ Object
Search image from style path.
- #stylesheet(*args) ⇒ Object
- #title(page_title, show_title = true) ⇒ Object
Instance Method Details
#javascript(*args) ⇒ Object
31 32 33 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 31 def javascript(*args) content_for(:head) { javascript_include_tag(*args) } end |
#page_entries_info(collection, singular_model_name, plural_model_name = nil) ⇒ Object
Show search informations
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 41 def page_entries_info(collection, singular_model_name, plural_model_name=nil) html = "" html << content_tag(:div, nil, :class => "separator") html << content_tag(:span, :class => "page_info") do if collection.any? t(:search_found, :found => pluralize(collection.total_count, singular_model_name, (plural_model_name || singular.pluralize))) else t(:search_not_found) end end html << content_tag(:div, nil, :class => "separator") html.html_safe end |
#secondary_navigation(*items) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 15 def (*items) outcome = '<ul>' items.compact.each do |h| outcome << "<li#{h[:active] ? " class='active'" : ""}>#{h[:value]}</li>" end outcome << '</ul>' outcome << '<div class="clear"></div>' content_for(:secondary_navigation) do outcome.html_safe end end |
#show_title? ⇒ Boolean
11 12 13 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 11 def show_title? @show_title end |
#style_image_tag(name, args = {}) ⇒ Object
Search image from style path
36 37 38 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 36 def style_image_tag(name,args={}) image_tag("styles/#{CONFIG[:default_style]}/#{name}",args) end |
#stylesheet(*args) ⇒ Object
27 28 29 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 27 def stylesheet(*args) content_for(:head) { stylesheet_link_tag(*args) } end |
#title(page_title, show_title = true) ⇒ Object
6 7 8 9 |
# File 'lib/generators/leolay/templates/app/helpers/layout_helper.rb', line 6 def title(page_title, show_title = true) content_for(:title) { page_title.to_s } @show_title = show_title end |