rblade 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89abc20ace497e0f051bb38ed620c44bf4bc7067cfeb20d7d7af9f13b98337ae
|
4
|
+
data.tar.gz: '0971c951b39f2cf94833a1d3d55eb3c561666995049d7d6f4fff553837615676'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73f515630bcfc90ea39862b6014d4b4a4afb4b29b33a09ae8ac58e8ead98786e26be03c4e63d5711c82a6728afd37e02549b56417bf5833d833d8f7ee473ed34
|
7
|
+
data.tar.gz: 8965f3fe015315e49c3dfe5b31b8aa949f0f609ffd7664a87ab875ca9a2f0cf494ac0a2236896479dfe007e2ebe45e5acdafbdb9d6384197acc9390383f7365e
|
data/CHANGELOG.md
CHANGED
@@ -147,7 +147,7 @@ module RBlade
|
|
147
147
|
\s*
|
148
148
|
>
|
149
149
|
)
|
150
|
-
/
|
150
|
+
/xm)
|
151
151
|
end
|
152
152
|
|
153
153
|
def tokenizeAttributes segment
|
@@ -181,7 +181,7 @@ module RBlade
|
|
181
181
|
)
|
182
182
|
)
|
183
183
|
(?=\s|$)
|
184
|
-
/
|
184
|
+
/xm).flatten.compact
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
@@ -3,10 +3,27 @@ module RBlade
|
|
3
3
|
@attributes = {}
|
4
4
|
def initialize attributes
|
5
5
|
@attributes = attributes
|
6
|
+
|
7
|
+
if !@attributes[:_class].nil?
|
8
|
+
@attributes[:class] = mergeClasses(@attributes[:class], @attributes.delete(:_class))
|
9
|
+
end
|
10
|
+
if !@attributes[:_style].nil?
|
11
|
+
@attributes[:style] = mergeClasses(@attributes[:style], @attributes.delete(:_style))
|
12
|
+
end
|
13
|
+
|
14
|
+
@attributes.freeze
|
6
15
|
end
|
7
16
|
|
8
17
|
def to_h
|
9
|
-
@attributes
|
18
|
+
attributes = @attributes.dup
|
19
|
+
if !attributes[:class].nil?
|
20
|
+
attributes[:_class] = attributes.delete :class
|
21
|
+
end
|
22
|
+
if !attributes[:style].nil?
|
23
|
+
attributes[:_style] = attributes.delete :style
|
24
|
+
end
|
25
|
+
|
26
|
+
attributes
|
10
27
|
end
|
11
28
|
|
12
29
|
def to_s attributes = nil
|
@@ -42,18 +59,12 @@ module RBlade
|
|
42
59
|
|
43
60
|
@attributes.each do |key, value|
|
44
61
|
if key == :class && !new_attributes[key].nil?
|
45
|
-
|
46
|
-
new_attributes[key] << " "
|
47
|
-
end
|
48
|
-
new_attributes[key] << value.to_s
|
62
|
+
new_attributes[key] = mergeClasses(new_attributes[key], value.to_s)
|
49
63
|
next
|
50
64
|
end
|
51
65
|
|
52
66
|
if key == :style && !new_attributes[key].nil?
|
53
|
-
|
54
|
-
new_attributes[key] << ";"
|
55
|
-
end
|
56
|
-
new_attributes[key] << value.to_s
|
67
|
+
new_attributes[key] = mergeStyles(new_attributes[key], value.to_s)
|
57
68
|
next
|
58
69
|
end
|
59
70
|
|
@@ -62,5 +73,41 @@ module RBlade
|
|
62
73
|
|
63
74
|
self.class.new new_attributes
|
64
75
|
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def mergeClasses(classes_1, classes_2)
|
80
|
+
if classes_1.nil?
|
81
|
+
return classes_2
|
82
|
+
end
|
83
|
+
if classes_2.nil?
|
84
|
+
return classes_1
|
85
|
+
end
|
86
|
+
|
87
|
+
classes_combined = classes_1
|
88
|
+
unless classes_combined.end_with? " "
|
89
|
+
classes_combined << " "
|
90
|
+
end
|
91
|
+
classes_combined << classes_2.to_s
|
92
|
+
|
93
|
+
classes_combined
|
94
|
+
end
|
95
|
+
|
96
|
+
def mergeStyles(styles_1, styles_2)
|
97
|
+
if styles_1.nil?
|
98
|
+
return styles_2
|
99
|
+
end
|
100
|
+
if styles_2.nil?
|
101
|
+
return styles_1
|
102
|
+
end
|
103
|
+
|
104
|
+
styles_combined = styles_1
|
105
|
+
unless styles_combined.end_with? ";"
|
106
|
+
styles_combined << ";"
|
107
|
+
end
|
108
|
+
styles_combined << styles_2.to_s
|
109
|
+
|
110
|
+
styles_combined
|
111
|
+
end
|
65
112
|
end
|
66
113
|
end
|
data/rblade.gemspec
CHANGED