Module: E9Rails::Helpers::Title::HelperMethods

Defined in:
lib/e9_rails/helpers/title.rb

Instance Method Summary collapse

Instance Method Details

#meta_title(title = nil, options = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/e9_rails/helpers/title.rb', line 10

def meta_title(title = nil, options = {})
  [
    title || @_title,
    respond_to?(:site_name) ? send(:site_name) : nil
  ].flatten.compact.map {|t| sanitize(t) }.join(options[:delimiter] || ' - ').html_safe
end

#title(*args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/e9_rails/helpers/title.rb', line 17

def title(*args)
  options = args.extract_options!

  if !args.empty?
    @_title    = args.dup
    base_title = sanitize(args.shift)

    options[:class] = [options[:class], 'title'].compact.join(' ')
    options[:class].concat(' error') if options[:error]

    unless options[:hide_title]
      content = base_title
      content = (options[:inner_tag], content) if options[:inner_tag]

      (:h1, options.slice(:id, :class)) do
        ''.tap do |html|
          html.concat options[:prepend] if options[:prepend]
          html.concat content
          html.concat options[:append] if options[:append]
        end
      end
    end
  end
end