module MetaTags::ViewHelper

def description(description)

Other tags:
    See: #display_meta_tags -

Returns:
  • (String) - passed value.

Parameters:
  • description (String) -- page description to be set in HEAD section of
def description(description)
  set_meta_tags(description: description)
  description
end

def display_meta_tags(defaults = {})

Returns:
  • (String) - HTML meta tags to render in HEAD section of the

Options Hash: (**default)
  • :open_search (Hash) -- add Open Search link tag.
  • :open_graph (Hash) -- add Open Graph meta tags.
  • :refresh (String, Integer) -- meta refresh tag;
  • :next (String) -- add next link tag.
  • :prev (String) -- add prev link tag;
  • :alternate (Hash) -- add alternate link tag.
  • :canonical (String) -- add canonical link tag.
  • :nofollow (Boolean, String) -- add nofollow meta tag; when true, 'robots' will be used,
  • :noindex (Boolean, String) -- add noindex meta tag; when true, 'robots' will be used,
  • :reverse (Boolean) -- when true, the page and site names will be reversed;
  • :lowercase (Boolean) -- when true, the page title will be lowercase;
  • :suffix (String, Boolean) -- text between separator and page title;
  • :separator (String) -- text used to separate website name from page title;
  • :prefix (String, Boolean) -- text between site name and separator;
  • :keywords (String) -- page keywords;
  • :description (String) -- page description;
  • :title (String) -- page title;
  • :site (String) -- site title;

Parameters:
  • defaults (Hash) -- default meta tag values.
def display_meta_tags(defaults = {})
  meta_tags.with_defaults(defaults) { Renderer.new(meta_tags).render(self) }
end

def display_title(defaults = {})

Options Hash: (**default)
  • :reverse (Boolean) -- when true, the page and site names will be reversed;
  • :lowercase (Boolean) -- when true, the page name will be lowercase;
  • :suffix (String, Boolean) -- text between separator and page title; when +false+,
  • :separator (String) -- text used to separate website name from page title;
  • :prefix (String, Boolean) -- text between site name and separator; when +false+,
  • :title (String) -- page title;
  • :site (String) -- site title;

Parameters:
  • defaults (Hash) -- list of meta tags.
def display_title(defaults = {})
  @meta_tags.full_title(defaults)
end

def keywords(keywords)

Other tags:
    See: #display_meta_tags -

Returns:
  • (String, Array) - passed value.

Parameters:
  • keywords (String, Array) -- meta keywords to render in HEAD
def keywords(keywords)
  set_meta_tags(keywords: keywords)
  keywords
end

def meta_tags

Get meta tags for the page.
def meta_tags
  @meta_tags ||= MetaTagsCollection.new
end

def nofollow(nofollow = true)

Other tags:
    See: #display_meta_tags -

Returns:
  • (Boolean, String, Array) - passed value.

Parameters:
  • nofollow (Boolean, String, Array) -- a nofollow value.
def nofollow(nofollow = true)
  set_meta_tags(nofollow: nofollow)
  nofollow
end

def noindex(noindex = true)

Other tags:
    See: #display_meta_tags -

Returns:
  • (Boolean, String, Array) - passed value.

Parameters:
  • noindex (Boolean, String, Array) -- a noindex value.
def noindex(noindex = true)
  set_meta_tags(noindex: noindex)
  noindex
end

def refresh(refresh)

Other tags:
    See: #display_meta_tags -

Returns:
  • (Integer, String) - passed value.

Parameters:
  • refresh (Integer, String) -- a refresh value.
def refresh(refresh)
  set_meta_tags(refresh: refresh)
  refresh
end

def set_meta_tags(meta_tags = {})

Other tags:
    See: #display_meta_tags -

Parameters:
  • meta_tags (Hash) -- list of meta tags. See {#display_meta_tags}
def set_meta_tags(meta_tags = {})
  self.meta_tags.update(meta_tags)
end

def title(title = nil, headline = '')

Other tags:
    See: #display_meta_tags -

Other tags:
    Example: Get current title -
    Example: Set title as array of strings -
    Example: Set HTML title to "Login Page", return "Please login" -
    Example: Set HTML title to "Please login", return "Please login" -

Returns:
  • (String) - returns +title+ value or +headline+ if passed.

Parameters:
  • headline (String) -- the value to return from method. Useful
  • title (nil, String, Array) -- page title. When passed as an
def title(title = nil, headline = '')
  set_meta_tags(title: title) unless title.nil?
  headline.presence || meta_tags[:title]
end