hamlit 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: b1f223deaa09a89576d6debe05ea810cdad593a1
4
- data.tar.gz: 6b67a1d276b04fa616e518be4b1595fcec341ed5
3
+ metadata.gz: 4ddd725e168d26ee17fdcfeeff3988fc46d1a3f2
4
+ data.tar.gz: 7007913e4c3109c688529e9cecf93ae5a5ac1a72
5
5
  SHA512:
6
- metadata.gz: 82ed8b2c6b39157869b9461f57698a1980a799f747ce3c8e89877036d9d64c08d60e7aa2e0038b88fbb621c41f7ee9a8a682f40b2356b17126bb57cec5c34848
7
- data.tar.gz: aeb9122f3392bf2fe9c0790ce7f29daf9fd35bc2016c50cac85d0d2ea46d0f5b04780821e356e0d841344b4f18cc0d17bac9c18058ab6970f9bbe221873c9f11
6
+ metadata.gz: c540899eece79a297d71d6d369d4aa65db1e9f145872ec1767778ae8ba55368d129cbed4f1a639163bd9904717dc36662ba368ad57f56c97af52edb02345dcac
7
+ data.tar.gz: 688cba8235f8978e30d98f731f711c1da70f554389ee1ec2dffab6f999d521c335229878bc37a40957558685fa637d5f0b5fd13cc78c5f65ed9242cf78f9a2b0
@@ -8,6 +8,7 @@ module Hamlit
8
8
  case value
9
9
  when Hash
10
10
  flatten_attributes(value).each do |k, v|
11
+ k = k.to_s.gsub(/_/, '-')
11
12
  flattened["#{key}-#{k}"] = v if v
12
13
  end
13
14
  else
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -40,23 +40,6 @@ describe Hamlit::Engine do
40
40
  HTML
41
41
  end
42
42
 
43
- it 'renders true attributes' do
44
- assert_render(<<-'HAML', <<-HTML)
45
- %span{ data: { disable: true } } bar
46
- HAML
47
- <span data-disable>bar</span>
48
- HTML
49
- end
50
-
51
- it 'renders nested hash whose value is variable' do
52
- assert_render(<<-'HAML', <<-HTML)
53
- - hash = { disable: true }
54
- %span{ data: hash } bar
55
- HAML
56
- <span data-disable>bar</span>
57
- HTML
58
- end
59
-
60
43
  it 'renders false or nil attributes' do
61
44
  assert_render(<<-'HAML', <<-HTML)
62
45
  - hash = { checked: false }
@@ -103,5 +86,60 @@ describe Hamlit::Engine do
103
86
  <span '<foo>'='&lt;bar&gt;'></span>
104
87
  HTML
105
88
  end
89
+
90
+ describe 'nested attributes' do
91
+ it 'renders true attributes' do
92
+ assert_render(<<-'HAML', <<-HTML)
93
+ %span{ data: { disable: true } } bar
94
+ HAML
95
+ <span data-disable>bar</span>
96
+ HTML
97
+ end
98
+
99
+ it 'renders nested hash whose value is variable' do
100
+ assert_render(<<-'HAML', <<-HTML)
101
+ - hash = { disable: true }
102
+ %span{ data: hash } bar
103
+ HAML
104
+ <span data-disable>bar</span>
105
+ HTML
106
+ end
107
+
108
+ it 'changes an underscore in a nested key to a hyphen' do
109
+ assert_render(<<-'HAML', <<-HTML)
110
+ %div{ data: { raw_src: 'foo' } }
111
+ HAML
112
+ <div data-raw-src='foo'></div>
113
+ HTML
114
+ end
115
+
116
+ it 'changes an underscore in a nested dynamic attribute' do
117
+ assert_render(<<-'HAML', <<-HTML)
118
+ - hash = { raw_src: 'foo' }
119
+ %div{ data: hash }
120
+ HAML
121
+ <div data-raw-src='foo'></div>
122
+ HTML
123
+ end
124
+ end
125
+
126
+ describe 'element class with attributes class' do
127
+ it 'does not generate double classes' do
128
+ assert_render(<<-HAML, <<-HTML)
129
+ .item{ class: 'first' }
130
+ HAML
131
+ <div class='first item'></div>
132
+ HTML
133
+ end
134
+
135
+ it 'does not generate double classes for a variable' do
136
+ assert_render(<<-HAML, <<-HTML)
137
+ - val = 'val'
138
+ .element{ class: val }
139
+ HAML
140
+ <div class='element val'></div>
141
+ HTML
142
+ end
143
+ end
106
144
  end
107
145
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun