Module: HtmlMeta
- Defined in:
- lib/html_meta.rb,
lib/html_meta/data.rb,
lib/html_meta/version.rb,
lib/html_meta/configuration.rb
Defined Under Namespace
Classes: Configuration, Data
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
10
11
12
|
# File 'lib/html_meta.rb', line 10
def configuration
self.configuration
end
|
.data ⇒ Object
Returns the value of attribute data.
14
15
16
|
# File 'lib/html_meta.rb', line 14
def data
@data
end
|
Class Method Details
16
17
18
19
20
|
# File 'lib/html_meta.rb', line 16
def configure
self.configuration ||= Configuration.new
yield(self.configuration) if block_given?
self.configuration
end
|
.define(&block) ⇒ Object
22
23
24
25
26
|
# File 'lib/html_meta.rb', line 22
def define(&block)
self.data ||= Data.new
raise ArgumentError.new("You must pass a block to the method") unless block_given?
self.data.instance_eval(&block)
end
|
28
29
30
31
|
# File 'lib/html_meta.rb', line 28
def meta(key, value = nil, options = {})
self.data ||= Data.new
self.data.meta(key, value, options)
end
|
.open_graph(key, value = nil, options = {}) ⇒ Object
Also known as:
og
33
34
35
36
|
# File 'lib/html_meta.rb', line 33
def open_graph(key, value = nil, options = {})
self.data ||= Data.new
self.data.open_graph(key, value, options)
end
|
.render ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/html_meta.rb', line 45
def render
self.data ||= Data.new
default = self.data.get(:default)
open_graph = self.data.get(:og)
html = Arbre::Context.new do
default.each do |key, value|
if key == :title
title value
else
meta(name: key.to_s, content: value)
end
end
open_graph.each do |key, value|
meta(property: 'og:' + key.to_s, content: value)
end
end
html.to_s
end
|
.reset ⇒ Object
40
41
42
43
|
# File 'lib/html_meta.rb', line 40
def reset
self.data ||= Data.new
self.data.reset
end
|