Module: Poodle::MetaTagsHelper

Defined in:
app/helpers/poodle/meta_tags_helper.rb

Instance Method Summary collapse

Instance Method Details

#meta_tagsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/poodle/meta_tags_helper.rb', line 3

def meta_tags
  return "" unless @meta_tags
  @meta_tags.reverse_merge!(
    "robots" => :all,
    "viewport" => "width=device-width, initial-scale=1.0",
    "copyright" => "2015 K P Varma",
    "content-language" => "en",
    "resource-type" => "document",
    "distribution" => "global",
    "rating" => "general"
  )

  link_tags_list = []
  meta_tags_list = []

  {
    prev: :rel_prev,
    next: :rel_next,
    canonical: :canonical
  }.each do |k, v|
    link_tags_list << (:link, "", rel: k, href: v) if @meta_tags[k]
  end

  {
    meta_description: :meta_description,
    meta_keywords: :meta_keywords,
    keywords: :keywords,
    robots: :robots
  }.each do |k, v|
    meta_tags_list << (:meta, "", name: k, content: v) if @meta_tags[k]
  end

  raw(link_tags_list.join(" ") + meta_tags_list.join(" "))

end