Module: Jekyll::HTML
- Defined in:
- lib/jekyll-html.rb,
lib/jekyll-html/end_tag.rb,
lib/jekyll-html/version.rb,
lib/jekyll-html/start_tag.rb
Defined Under Namespace
Classes: EndTag, StartTag
Constant Summary
collapse
- VERSION =
"1.0.2"
Class Method Summary
collapse
Class Method Details
.generate_end_tag(tag_content) ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/jekyll-html.rb', line 38
def generate_end_tag(tag_content)
raise("Tag content cannot be null!") if tag_content.nil?
raise("Tag content cannot be empty!") if tag_content.empty?
content = tag_content.split(" ")
raise("Splitted content cannot be empty!") if content.empty?
"</#{content[0]}>"
end
|
.generate_start_tag(tag_content) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/jekyll-html.rb', line 13
def generate_start_tag(tag_content)
raise("Tag content cannot be null!") if tag_content.nil?
raise("Tag content cannot be empty!") if tag_content.empty?
content = tag_content.split(" ")
raise("Splitted content cannot be empty!") if content.empty?
result = ""
content.each do |target|
target_content = target.split("=")
if target_content.length != 2
result += target + " "
next
end
key = target_content[0]
value = target_content[1].tr("_", " ")
result += "#{key}=\"#{value}\"\""
end
"<#{result[0, result.length - 1]}>"
end
|