Sha256: 56c31ae52161fd9902056394e56ddf5677d066380815cfae6d9eeba22fb1d1b8
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
module TopHat module TitleHelper def title(title=nil, options={}) if title.is_a?(String) || title.is_a?(Array) save_tophat_title(title, options) else display_tophat_title(title || options) end end private def save_tophat_title(title, options) @tophat_title = title @tophat_title_options = options title end def display_tophat_title(options) options = options.merge(@tophat_title_options) unless @tophat_title_options.nil? title_segments = [] title_segments << options[:site] if options[:site] title_segments << (@tophat_title.blank? ? options[:default] : @tophat_title) title_segments.flatten! # flatten out in case the title is an array title_segments.compact! # clean out any nils title_segments.map! { |t| t.downcase! } if options[:lowercase] title_segments.map! { |t| t.upcase! } if options[:uppercase] title_segments.map! { |t| strip_tags(t) } reverse = options[:reverse] reverse = false if options[:default] && @tophat_title.blank? && options[:reverse_on_default] == false title_segments.reverse! if reverse content_tag :title, title_segments.join(delimiter_from(options)).strip end alias t title def delimiter_from(options={}) return "" if options.empty? # Prefix (leading space) if options[:prefix] prefix = options[:prefix] elsif options[:prefix] == false prefix = '' else prefix = ' ' end # Separator separator = options[:separator] || '' # Suffix (trailing space) if options[:suffix] suffix = options[:suffix] elsif options[:suffix] == false suffix = '' else suffix = ' ' end prefix + separator + suffix end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tophat-1.3.1 | lib/tophat/title.rb |