Class: Storyblok::Richtext::Marks::Link
- Inherits:
-
Mark
- Object
- Mark
- Storyblok::Richtext::Marks::Link
show all
- Defined in:
- lib/storyblok/richtext/html_renderer/marks/link.rb
Instance Attribute Summary
Attributes inherited from Mark
#type
Instance Method Summary
collapse
Methods inherited from Mark
#initialize
Instance Method Details
#matching ⇒ Object
5
6
7
|
# File 'lib/storyblok/richtext/html_renderer/marks/link.rb', line 5
def matching
@node['type'] === 'link'
end
|
#tag ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/storyblok/richtext/html_renderer/marks/link.rb', line 9
def tag
attrs = @node['attrs']
if attrs['anchor'].is_a?(String) and !attrs['anchor'].empty?
attrs['href'] = "#{attrs['href']}##{attrs['anchor']}"
attrs.delete('anchor')
end
if attrs['linktype'].is_a?(String) and attrs['linktype'] == 'email'
emailContainer = attrs['href']
attrs['href'] = "mailto:#{emailContainer}"
end
if attrs['custom'].is_a?(Hash)
for item in attrs['custom'] do
attrs[item[0]] = item[1]
end
attrs.delete('custom')
end
[{
tag: "a",
attrs: attrs
}]
end
|