Class: PageMeta::MetaTag
- Inherits:
-
Object
- Object
- PageMeta::MetaTag
- Defined in:
- lib/page_meta/meta_tag.rb,
lib/page_meta/meta_tag/og.rb,
lib/page_meta/meta_tag/title.rb,
lib/page_meta/meta_tag/charset.rb,
lib/page_meta/meta_tag/twitter.rb,
lib/page_meta/meta_tag/language.rb,
lib/page_meta/meta_tag/dns_prefetch_control.rb
Direct Known Subclasses
HashMetaTag, Charset, DnsPrefetchControl, HttpEquiv, Language, MultipleMetaTag, Title
Defined Under Namespace
Classes: Author, CacheControl, Charset, Description, DnsPrefetchControl, Expires, HttpEquiv, Imagetoolbar, Keywords, Language, MultipleMetaTag, Og, Pragma, Refresh, Title, Twitter
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
- #helpers ⇒ Object
-
#initialize(name, content) ⇒ MetaTag
constructor
A new instance of MetaTag.
- #render ⇒ Object
Constructor Details
#initialize(name, content) ⇒ MetaTag
Returns a new instance of MetaTag.
17 18 19 20 |
# File 'lib/page_meta/meta_tag.rb', line 17 def initialize(name, content) @name = name.to_s.dasherize @raw_content = content end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/page_meta/meta_tag.rb', line 5 def name @name end |
Class Method Details
.build(name, content) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/page_meta/meta_tag.rb', line 7 def self.build(name, content) klass_name = "::PageMeta::MetaTag::#{name.to_s.camelize}" klass = begin const_get(klass_name) rescue ActionView::Template::Error, NameError MetaTag end klass.new(name, content) end |
Instance Method Details
#content ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/page_meta/meta_tag.rb', line 22 def content @content ||= if @raw_content.respond_to?(:call) @raw_content.call else @raw_content end end |
#helpers ⇒ Object
34 35 36 |
# File 'lib/page_meta/meta_tag.rb', line 34 def helpers ActionController::Base.helpers end |
#render ⇒ Object
30 31 32 |
# File 'lib/page_meta/meta_tag.rb', line 30 def render helpers.tag(:meta, name:, content:) unless content.blank? end |