rblade 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 418e9e009d866abaf770d8fee42675919627c041fdb6753a628710d41875d75d
|
4
|
+
data.tar.gz: 4f51870487d92dadbc8fddcd413c26cbcade77cc5bdd16b3be664912c0de70ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99a62b7cd0e707fce89b84cc082daaff2776b32d16b170f502db8b5b42dc2dd89d0c821d78a24ac2ebb0c8ef99442373b5ca2464a726d037b9fded893e625659
|
7
|
+
data.tar.gz: bf2d3d6ae6437ecf9a770180ea9cf8d3becd1223375313d3027ce16252d0083cb91b712067bb1a0da7e157e98041c8251edfc043229e1824c85e119640e60427
|
data/CHANGELOG.md
CHANGED
@@ -11,9 +11,9 @@ module RBlade
|
|
11
11
|
props = extractProps args[0]
|
12
12
|
props.map do |key, value|
|
13
13
|
if value == "_required"
|
14
|
-
"if !defined?(#{key});raise \"Props statement: #{key} is not defined\";end;"
|
14
|
+
"if !defined?(#{key})&&!attributes.has?(:'#{RBlade::escape_quotes(key)}');raise \"Props statement: #{key} is not defined\";end;#{key.sub /[^a-zA-Z0-9_]/, '_'}=attributes.default(:'#{RBlade::escape_quotes(key)}');"
|
15
15
|
else
|
16
|
-
"
|
16
|
+
"#{key.sub /[^a-zA-Z0-9_]/, '_'}=attributes.default(:'#{RBlade::escape_quotes(key)}',#{value});"
|
17
17
|
end
|
18
18
|
end.join
|
19
19
|
end
|
@@ -3,10 +3,39 @@ 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
|
15
|
+
end
|
16
|
+
|
17
|
+
def default(key, default = nil)
|
18
|
+
if @attributes[key].nil? && !default.nil?
|
19
|
+
@attributes[key] = default
|
20
|
+
end
|
21
|
+
|
22
|
+
@attributes[key]
|
23
|
+
end
|
24
|
+
|
25
|
+
def has?(key)
|
26
|
+
!@attributes[key].nil?
|
6
27
|
end
|
7
28
|
|
8
29
|
def to_h
|
9
|
-
@attributes
|
30
|
+
attributes = @attributes.dup
|
31
|
+
if !attributes[:class].nil?
|
32
|
+
attributes[:_class] = attributes.delete :class
|
33
|
+
end
|
34
|
+
if !attributes[:style].nil?
|
35
|
+
attributes[:_style] = attributes.delete :style
|
36
|
+
end
|
37
|
+
|
38
|
+
attributes
|
10
39
|
end
|
11
40
|
|
12
41
|
def to_s attributes = nil
|
@@ -42,18 +71,12 @@ module RBlade
|
|
42
71
|
|
43
72
|
@attributes.each do |key, value|
|
44
73
|
if key == :class && !new_attributes[key].nil?
|
45
|
-
|
46
|
-
new_attributes[key] << " "
|
47
|
-
end
|
48
|
-
new_attributes[key] << value.to_s
|
74
|
+
new_attributes[key] = mergeClasses(new_attributes[key], value.to_s)
|
49
75
|
next
|
50
76
|
end
|
51
77
|
|
52
78
|
if key == :style && !new_attributes[key].nil?
|
53
|
-
|
54
|
-
new_attributes[key] << ";"
|
55
|
-
end
|
56
|
-
new_attributes[key] << value.to_s
|
79
|
+
new_attributes[key] = mergeStyles(new_attributes[key], value.to_s)
|
57
80
|
next
|
58
81
|
end
|
59
82
|
|
@@ -62,5 +85,41 @@ module RBlade
|
|
62
85
|
|
63
86
|
self.class.new new_attributes
|
64
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def mergeClasses(classes_1, classes_2)
|
92
|
+
if classes_1.nil?
|
93
|
+
return classes_2
|
94
|
+
end
|
95
|
+
if classes_2.nil?
|
96
|
+
return classes_1
|
97
|
+
end
|
98
|
+
|
99
|
+
classes_combined = classes_1
|
100
|
+
unless classes_combined.end_with? " "
|
101
|
+
classes_combined << " "
|
102
|
+
end
|
103
|
+
classes_combined << classes_2.to_s
|
104
|
+
|
105
|
+
classes_combined
|
106
|
+
end
|
107
|
+
|
108
|
+
def mergeStyles(styles_1, styles_2)
|
109
|
+
if styles_1.nil?
|
110
|
+
return styles_2
|
111
|
+
end
|
112
|
+
if styles_2.nil?
|
113
|
+
return styles_1
|
114
|
+
end
|
115
|
+
|
116
|
+
styles_combined = styles_1
|
117
|
+
unless styles_combined.end_with? ";"
|
118
|
+
styles_combined << ";"
|
119
|
+
end
|
120
|
+
styles_combined << styles_2.to_s
|
121
|
+
|
122
|
+
styles_combined
|
123
|
+
end
|
65
124
|
end
|
66
125
|
end
|
data/rblade.gemspec
CHANGED