hypertext 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hypertext.gemspec +1 -1
- data/lib/hypertext.rb +11 -5
- data/lib/hypertext/dsl.rb +8 -0
- data/test/all.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b974b055063680c076cf29632fd9213845f29cded66964e0b4d94eeb12dce3b6
|
4
|
+
data.tar.gz: 763f98b84eac1550e2cafd5314a8b41b5d3245e9697db63e5fa6cebc250a8e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0325888451cf71a459f91c854a3992fc08c337e5c4a1caf25a03759ce9fc368b9f434901bd33fa4b980119a57cd2be103003ec9a0bd15886d963093c9b1051c
|
7
|
+
data.tar.gz: ac7af6f6f5a0f1166115923876bc6ceced66f721830be0b7b1e0db715f23bd849a32d1c16125e96da933ccb6e5f120ce2f524f1ecd190a218cc99fe3be5b0ac7
|
data/hypertext.gemspec
CHANGED
data/lib/hypertext.rb
CHANGED
@@ -30,11 +30,13 @@ class Hypertext
|
|
30
30
|
}
|
31
31
|
|
32
32
|
def self.render(array, indent = " ", level = 0)
|
33
|
+
indentation = indent * level
|
34
|
+
|
33
35
|
array.map do |element|
|
34
36
|
if Array === element
|
35
37
|
render(element, indent, level + 1)
|
36
38
|
else
|
37
|
-
sprintf "%s%s\n",
|
39
|
+
sprintf "%s%s\n", indentation, element
|
38
40
|
end
|
39
41
|
end.join
|
40
42
|
end
|
@@ -51,24 +53,28 @@ class Hypertext
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
56
|
+
def append(value)
|
57
|
+
@dom.push(*value)
|
58
|
+
end
|
59
|
+
|
54
60
|
def tag(name, attributes = {})
|
55
61
|
atts = compile(attributes)
|
56
62
|
|
57
63
|
if block_given?
|
58
|
-
|
64
|
+
append("<#{name}#{atts}>")
|
59
65
|
|
60
66
|
original, @dom = @dom, []
|
61
67
|
yield
|
62
68
|
@dom = original << @dom
|
63
69
|
|
64
|
-
|
70
|
+
append("</#{name}>")
|
65
71
|
else
|
66
|
-
|
72
|
+
append("<#{name}#{atts} />")
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
70
76
|
def text(value)
|
71
|
-
|
77
|
+
append(escape(value))
|
72
78
|
end
|
73
79
|
|
74
80
|
def to_a
|
data/lib/hypertext/dsl.rb
CHANGED
data/test/all.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypertext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cutest
|