Class: MetaTags::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_tags-rails/renderer.rb

Overview

This class is used by MetaTags gems to render HTML meta tags into page.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(meta_tags) ⇒ Renderer

Initialized a new instance of Renderer.

Parameters:



10
11
12
13
# File 'lib/meta_tags-rails/renderer.rb', line 10

def initialize(meta_tags)
  @meta_tags = meta_tags
  @normalized_meta_tags = {}
end

Instance Attribute Details

#meta_tagsObject (readonly)

Returns the value of attribute meta_tags.



4
5
6
# File 'lib/meta_tags-rails/renderer.rb', line 4

def meta_tags
  @meta_tags
end

#normalized_meta_tagsObject (readonly)

Returns the value of attribute normalized_meta_tags.



4
5
6
# File 'lib/meta_tags-rails/renderer.rb', line 4

def normalized_meta_tags
  @normalized_meta_tags
end

Instance Method Details

#render(view) ⇒ Object

Renders meta tags on the page.

Parameters:

  • view (ActionView::Base)

    Rails view object.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/meta_tags-rails/renderer.rb', line 18

def render(view)
  tags = []

  render_charset(tags)
  render_title(tags)
  render_icon(tags)
  render_with_normalization(tags, :description)
  render_with_normalization(tags, :keywords)
  render_refresh(tags)
  render_noindex(tags)
  render_alternate(tags)
  render_open_search(tags)
  render_links(tags)

  render_hash(tags, :og, name_key: :property)
  render_hash(tags, :fb, name_key: :property)
  render_hash(tags, :al, name_key: :property)
  render_hash(tags, :article, name_key: :property)

  render_hashes(tags)
  render_custom(tags)

  tags.compact.map { |tag| tag.render(view) }.join("\n").html_safe
end