Sha256: dc444acdc2bfec061ab62ffaf62294f5079fc1c2151c582bb1b926e23bac8e0b

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module RailstarHelper
  def title(page_title)
    content_for(:title) { page_title }
  end

  def stylesheet(*css)
    content_for(:head) { stylesheet_link_tag(*css) }
  end

  def javascript(*js)
    content_for(:head) { javascript_include_tag(*js) }
  end

  def auto_discovery_rss(rss)
    content_for(:head) do
      %Q(<link rel="alternate" type="application/rss+xml" href="#{rss}" title="RSS 2.0" />)
    end
  end

  def hbr(str)
    str = html_escape(str)
    br(str)
  end

  def br(str)
    str.gsub(/\r\n|\r|\n/, "<br />")
  end

  def url2link(str)
    str.gsub(/(https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:@&=+$,%#]+)/){"<a href='#{$1}'>#{$1}</a>"}
  end

  def params_to_hidden_tag(object, options={})
    p = params[object]
    str = ""
    str << hidden_field_tag('back', 1) if options[:back]
    return str unless p
    p.each do |method,value|
      if options[:except] && options[:except].include?(method.to_sym)
      else
        str << hidden_field(object,method, :value => p[method])
      end
    end
    str
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
railstar-0.0.0 lib/railstar_helper.rb