Sha256: 866c1b0941a8693d5c4c7ed483f77e0b1d9c7ca0aad3c7ef596d61fda76457fe

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# 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
module LayoutHelper
  def title(page_title, show_title = true)
    @content_for_title = page_title.to_s
    @show_title = show_title
  end
  
  def show_title?
    @show_title
  end
  
  def stylesheet(*args)
    content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) }
  end
  
  def javascript(*args)
    args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
    content_for(:head) { javascript_include_tag(*args) }
  end

  def tab(identifier)
    @current_tab = identifier
  end

  def show_tab(identifier, link = "#", link_options = {}, list_options = {})
    text = t(identifier, :scope => :tabs, :default => identifier.to_s.titleize)
    list_options[:class] = :current if identifier == @current_tab
    content_tag(:li, link_to(text, link, link_options), list_options)
  end

  def cancel_link
    if session[:back]
      link = link_to(t(:cancel), session[:back], :confirm => h(t(:confirm_cancel)))
      content_tag(:small, link, :class => "cancel")
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iain-pizza-generators-0.1.1 rails_generators/pizza_layout/templates/helper.rb
iain-pizza-generators-0.1.2 rails_generators/pizza_layout/templates/helper.rb
iain-pizza-generators-0.1.3 rails_generators/pizza_layout/templates/helper.rb
iain-pizza-generators-0.1.4 rails_generators/pizza_layout/templates/helper.rb