Class: MetaTags::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_tags/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:



12
13
14
15
# File 'lib/meta_tags/renderer.rb', line 12

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.



6
7
8
# File 'lib/meta_tags/renderer.rb', line 6

def meta_tags
  @meta_tags
end

#normalized_meta_tagsObject (readonly)

Returns the value of attribute normalized_meta_tags.



6
7
8
# File 'lib/meta_tags/renderer.rb', line 6

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.



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

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_canonical_link(tags)
  render_noindex(tags)
  render_alternate(tags)
  render_open_search(tags)
  render_links(tags)

  render_hashes(tags)
  render_custom(tags)

  tags.tap(&:compact!).map! { |tag| tag.render(view) }
  view.safe_join tags, MetaTags.config.minify_output ? "" : "\n"
end