hamlit 1.4.6 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/hamlit/attribute.rb +2 -2
- data/lib/hamlit/compilers/attributes.rb +10 -6
- data/lib/hamlit/version.rb +1 -1
- data/spec/hamlit/engine/old_attributes_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3045e96b4ecfe58f815e7d1fd326c1794b03c66f
|
4
|
+
data.tar.gz: e5c45da5f9a6a2ccfab6e102c47f1d9927098d65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d80b09e16c7707191fede2b060cc6c7a3f1db422ddaad0be03f3e8cbaa9b395ac04f74f4d396a781de11616bad672a61221501cac3f2d184c4be9453e6af89c
|
7
|
+
data.tar.gz: 45e2ee5c7d2f955f15e3093f0f1f87db2783e78b4baf9f1cdedcafb84568e4d5f78c85563461f845f254db80524600f6ceede60a8313d2817af3de248ab2ec79
|
data/CHANGELOG.md
CHANGED
data/lib/hamlit/attribute.rb
CHANGED
@@ -61,8 +61,8 @@ module Hamlit
|
|
61
61
|
case key
|
62
62
|
when :id
|
63
63
|
result[key] = [base[key], target[key]].compact.join('_')
|
64
|
-
|
65
|
-
result[key] = [base[key], target[key]].compact.map(&:to_s).sort.join(' ')
|
64
|
+
when :class
|
65
|
+
result[key] = [base[key], target[key]].flatten.compact.map(&:to_s).sort.join(' ')
|
66
66
|
end
|
67
67
|
else
|
68
68
|
result[key] = base[key].nil? ? target[key] : base[key]
|
@@ -22,7 +22,7 @@ module Hamlit
|
|
22
22
|
attrs = compile_attributes(attrs)
|
23
23
|
attrs = join_ids(attrs)
|
24
24
|
attrs = combine_classes(attrs)
|
25
|
-
attrs =
|
25
|
+
attrs = sort_attributes(attrs)
|
26
26
|
|
27
27
|
if has_runtime_attribute?(attrs) && has_attr?(attrs, 'class', 'id')
|
28
28
|
attrs = merge_runtime_attributes(attrs)
|
@@ -60,11 +60,6 @@ module Hamlit
|
|
60
60
|
attrs
|
61
61
|
end
|
62
62
|
|
63
|
-
def pull_class_first(attrs)
|
64
|
-
class_attrs = filter_attrs(attrs, 'class')
|
65
|
-
combine_classes(class_attrs) + (attrs - class_attrs)
|
66
|
-
end
|
67
|
-
|
68
63
|
def combine_classes(attrs)
|
69
64
|
class_attrs = filter_attrs(attrs, 'class')
|
70
65
|
return attrs if class_attrs.length <= 1
|
@@ -99,6 +94,15 @@ module Hamlit
|
|
99
94
|
end
|
100
95
|
result
|
101
96
|
end
|
97
|
+
|
98
|
+
# Sort attributes by attribute name.
|
99
|
+
# Move runtime attributes to last.
|
100
|
+
def sort_attributes(attrs)
|
101
|
+
attrs.sort_by do |(sexp, _, attr_name, _)|
|
102
|
+
next '' if sexp == :runtime
|
103
|
+
attr_name
|
104
|
+
end
|
105
|
+
end
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
data/lib/hamlit/version.rb
CHANGED
@@ -64,6 +64,16 @@ describe Hamlit::Engine do
|
|
64
64
|
HTML
|
65
65
|
end
|
66
66
|
|
67
|
+
it 'sorts static attributes by name' do
|
68
|
+
assert_render(<<-HAML, <<-HTML)
|
69
|
+
%span{ :foo => "bar", :hoge => "piyo"}
|
70
|
+
%span{ :hoge => "piyo", :foo => "bar"}
|
71
|
+
HAML
|
72
|
+
<span foo='bar' hoge='piyo'></span>
|
73
|
+
<span foo='bar' hoge='piyo'></span>
|
74
|
+
HTML
|
75
|
+
end
|
76
|
+
|
67
77
|
describe 'runtime attributes' do
|
68
78
|
it 'renders runtime hash attribute' do
|
69
79
|
assert_render(<<-'HAML', <<-HTML)
|
@@ -111,6 +121,18 @@ describe Hamlit::Engine do
|
|
111
121
|
HTML
|
112
122
|
end
|
113
123
|
|
124
|
+
it 'joins attribute class and element class' do
|
125
|
+
assert_render(<<-HAML, <<-HTML)
|
126
|
+
.foo{ class: ['bar'] }
|
127
|
+
.foo{ class: ['bar', nil] }
|
128
|
+
.foo{ class: ['bar', 'baz'] }
|
129
|
+
HAML
|
130
|
+
<div class='bar foo'></div>
|
131
|
+
<div class='bar foo'></div>
|
132
|
+
<div class='bar baz foo'></div>
|
133
|
+
HTML
|
134
|
+
end
|
135
|
+
|
114
136
|
it 'joins id with an underscore' do
|
115
137
|
assert_render(<<-'HAML', <<-HTML)
|
116
138
|
- val = ['a', 'b', 'c']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|