Module: SmartMeta

Defined in:
lib/smart_meta.rb

Instance Method Summary collapse

Instance Method Details

#smart_descriptionObject



14
15
16
# File 'lib/smart_meta.rb', line 14

def smart_description
  smart_meta_for(:description)
end

#smart_keywordsObject



18
19
20
# File 'lib/smart_meta.rb', line 18

def smart_keywords
  smart_meta_for(:keywords)
end

#smart_meta_for(kind) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/smart_meta.rb', line 2

def smart_meta_for(kind)
  key = [params[:controller], params[:action], kind].compact.join('.')
  if (title_template = translation_for(key))
    needed_args = title_template.scan(/\{\{(.*?)\}\}/).flatten
    args = needed_args.inject({}) do |hash, arg|
      hash[arg.to_sym] = value_from_arg(arg)
      hash
    end
    I18n.t(key, args)
  end
end

#smart_titleObject



22
23
24
# File 'lib/smart_meta.rb', line 22

def smart_title
  smart_meta_for(:title)
end