hamlit 1.6.4 → 1.6.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
  SHA1:
3
- metadata.gz: cc6af6b57be662141cab0bb717a24bdaf2e2406f
4
- data.tar.gz: 65ce818ede5672f94b126ec19cc3a210a28c705e
3
+ metadata.gz: e5cc29adeedc23941351000259c916d89cdea442
4
+ data.tar.gz: affff05b7d78d2c7af5dd23a7c1d7ecd01e15bd1
5
5
  SHA512:
6
- metadata.gz: b1e3e8153d7f4978de1ab3992d46b67dd00399d7bb789a93a8d2b6e7c6c91a20e7662d93d99369f7f7faf4f7f12b260b499d98c34dea286fede0177ee81548e0
7
- data.tar.gz: 04d290e8d75dc51ecd31e5c0f404bdb200b7d42fb528f2612054a05efeb59f8fb09c37b9297c780bf22087de3174070a5e51d1febca667c2a45080fd73eec1b1
6
+ metadata.gz: ea281451bd2d83164bd6a6d8b40c129d8551d06ebc64403e2bcbe5c9f4777dc7c911b385ef7077107a5e05b325e1fbcd844729569b2db6f8d4217bc6bf480268
7
+ data.tar.gz: 906d0de6f993ffc61831c3660399a8186e8d17a89bb89f3fff9af07d46e90ccdad7575a90c4630cf172d09ae6dd01e4bcb577837672a7949866a4e4c3990b4e3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.6.5
2
+
3
+ - Don't duplicate element class and attribute class
4
+ - Raise an error for an empty tag name
5
+
1
6
  ## v1.6.4
2
7
 
3
8
  - Show human-friendly error messages
@@ -30,6 +30,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
30
30
  ## Input
31
31
  ```haml
32
32
  .foo{ class: ['bar'] }
33
+ .foo{ class: ['bar', 'foo'] }
33
34
  .foo{ class: ['bar', nil] }
34
35
  .foo{ class: ['bar', 'baz'] }
35
36
 
@@ -40,6 +41,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
40
41
  ```html
41
42
  <div class='bar foo'></div>
42
43
  <div class='bar foo'></div>
44
+ <div class='bar foo'></div>
43
45
  <div class='bar baz foo'></div>
44
46
 
45
47
  ```
@@ -47,13 +49,14 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
47
49
  ### Faml
48
50
  ```html
49
51
  <div class='bar foo'></div>
52
+ <div class='bar foo'></div>
50
53
  <div class=' bar foo'></div>
51
54
  <div class='bar baz foo'></div>
52
55
 
53
56
  ```
54
57
 
55
58
 
56
- # [old\_attributes\_spec.rb:201](/spec/hamlit/engine/old_attributes_spec.rb#L201)
59
+ # [old\_attributes\_spec.rb:203](/spec/hamlit/engine/old_attributes_spec.rb#L203)
57
60
  ## Input
58
61
  ```haml
59
62
  / wontfix: Non-boolean attributes are not escaped for optimization.
@@ -94,7 +97,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
94
97
  ```
95
98
 
96
99
 
97
- # [old\_attributes\_spec.rb:226](/spec/hamlit/engine/old_attributes_spec.rb#L226)
100
+ # [old\_attributes\_spec.rb:228](/spec/hamlit/engine/old_attributes_spec.rb#L228)
98
101
  ## Input
99
102
  ```haml
100
103
  %a{title: "'"}
@@ -121,7 +124,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
121
124
  ```
122
125
 
123
126
 
124
- # [old\_attributes\_spec.rb:238](/spec/hamlit/engine/old_attributes_spec.rb#L238)
127
+ # [old\_attributes\_spec.rb:240](/spec/hamlit/engine/old_attributes_spec.rb#L240)
125
128
  ## Input
126
129
  ```haml
127
130
  - title = "'\""
@@ -147,7 +150,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
147
150
  ```
148
151
 
149
152
 
150
- # [old\_attributes\_spec.rb:250](/spec/hamlit/engine/old_attributes_spec.rb#L250)
153
+ # [old\_attributes\_spec.rb:252](/spec/hamlit/engine/old_attributes_spec.rb#L252)
151
154
  ## Input
152
155
  ```haml
153
156
  - title = { title: "'\"" }
@@ -173,7 +176,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
173
176
  ```
174
177
 
175
178
 
176
- # [old\_attributes\_spec.rb:273](/spec/hamlit/engine/old_attributes_spec.rb#L273)
179
+ # [old\_attributes\_spec.rb:275](/spec/hamlit/engine/old_attributes_spec.rb#L275)
177
180
  ## Input
178
181
  ```haml
179
182
  %span{ data: { disable: true } } bar
@@ -22,6 +22,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
22
22
  ## Input
23
23
  ```haml
24
24
  .foo{ class: ['bar'] }
25
+ .foo{ class: ['bar', 'foo'] }
25
26
  .foo{ class: ['bar', nil] }
26
27
  .foo{ class: ['bar', 'baz'] }
27
28
 
@@ -31,6 +32,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
31
32
  ### Faml
32
33
  ```html
33
34
  <div class='bar foo'></div>
35
+ <div class='bar foo'></div>
34
36
  <div class=' bar foo'></div>
35
37
  <div class='bar baz foo'></div>
36
38
 
@@ -40,12 +42,13 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
40
42
  ```html
41
43
  <div class='bar foo'></div>
42
44
  <div class='bar foo'></div>
45
+ <div class='bar foo'></div>
43
46
  <div class='bar baz foo'></div>
44
47
 
45
48
  ```
46
49
 
47
50
 
48
- # [old\_attributes\_spec.rb:201](/spec/hamlit/engine/old_attributes_spec.rb#L201)
51
+ # [old\_attributes\_spec.rb:203](/spec/hamlit/engine/old_attributes_spec.rb#L203)
49
52
  ## Input
50
53
  ```haml
51
54
  / wontfix: Non-boolean attributes are not escaped for optimization.
@@ -86,7 +89,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
86
89
  ```
87
90
 
88
91
 
89
- # [old\_attributes\_spec.rb:273](/spec/hamlit/engine/old_attributes_spec.rb#L273)
92
+ # [old\_attributes\_spec.rb:275](/spec/hamlit/engine/old_attributes_spec.rb#L275)
90
93
  ## Input
91
94
  ```haml
92
95
  %span{ data: { disable: true } } bar
@@ -21,7 +21,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
21
21
  ```
22
22
 
23
23
 
24
- # [old\_attributes\_spec.rb:201](/spec/hamlit/engine/old_attributes_spec.rb#L201)
24
+ # [old\_attributes\_spec.rb:203](/spec/hamlit/engine/old_attributes_spec.rb#L203)
25
25
  ## Input
26
26
  ```haml
27
27
  / wontfix: Non-boolean attributes are not escaped for optimization.
@@ -62,7 +62,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
62
62
  ```
63
63
 
64
64
 
65
- # [old\_attributes\_spec.rb:226](/spec/hamlit/engine/old_attributes_spec.rb#L226)
65
+ # [old\_attributes\_spec.rb:228](/spec/hamlit/engine/old_attributes_spec.rb#L228)
66
66
  ## Input
67
67
  ```haml
68
68
  %a{title: "'"}
@@ -89,7 +89,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
89
89
  ```
90
90
 
91
91
 
92
- # [old\_attributes\_spec.rb:238](/spec/hamlit/engine/old_attributes_spec.rb#L238)
92
+ # [old\_attributes\_spec.rb:240](/spec/hamlit/engine/old_attributes_spec.rb#L240)
93
93
  ## Input
94
94
  ```haml
95
95
  - title = "'\""
@@ -115,7 +115,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
115
115
  ```
116
116
 
117
117
 
118
- # [old\_attributes\_spec.rb:250](/spec/hamlit/engine/old_attributes_spec.rb#L250)
118
+ # [old\_attributes\_spec.rb:252](/spec/hamlit/engine/old_attributes_spec.rb#L252)
119
119
  ## Input
120
120
  ```haml
121
121
  - title = { title: "'\"" }
@@ -62,7 +62,7 @@ module Hamlit
62
62
  when :id
63
63
  result[key] = [base[key], target[key]].compact.join('_')
64
64
  when :class
65
- result[key] = [base[key], target[key]].flatten.compact.map(&:to_s).sort.join(' ')
65
+ result[key] = [base[key], target[key]].flatten.compact.map(&:to_s).sort.uniq.join(' ')
66
66
  end
67
67
  else
68
68
  result[key] = base[key].nil? ? target[key] : base[key]
@@ -15,8 +15,13 @@ module Hamlit
15
15
  DEFAULT_TAG = 'div'
16
16
 
17
17
  def parse_tag(scanner)
18
- tag = DEFAULT_TAG
19
- tag = scanner.scan(TAG_REGEXP) if scanner.scan(/%/)
18
+ if scanner.scan(/%/)
19
+ tag = scanner.scan(TAG_REGEXP)
20
+ unless tag
21
+ syntax_error!(%Q{Invalid tag: "#{scanner.string}".})
22
+ end
23
+ end
24
+ tag ||= DEFAULT_TAG
20
25
 
21
26
  attrs = [:haml, :attrs]
22
27
  attrs += parse_tag_id_and_class(scanner)
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = "1.6.4"
2
+ VERSION = "1.6.5"
3
3
  end
@@ -124,9 +124,11 @@ describe Hamlit::Engine do
124
124
  it 'joins attribute class and element class' do
125
125
  assert_render(<<-HAML, <<-HTML, compatible_only: :haml)
126
126
  .foo{ class: ['bar'] }
127
+ .foo{ class: ['bar', 'foo'] }
127
128
  .foo{ class: ['bar', nil] }
128
129
  .foo{ class: ['bar', 'baz'] }
129
130
  HAML
131
+ <div class='bar foo'></div>
130
132
  <div class='bar foo'></div>
131
133
  <div class='bar foo'></div>
132
134
  <div class='bar baz foo'></div>
@@ -219,5 +219,21 @@ describe Hamlit::Engine do
219
219
  specify { assert_render('あ#{"い"}う', "あいう\n") }
220
220
  specify { assert_render('a#{"<b>"}c', "a&lt;b&gt;c\n") }
221
221
  end
222
+
223
+ describe 'illegal inputs' do
224
+ it 'rejects an invalid tag' do
225
+ expect { render_string(<<-HAML.unindent) }.
226
+ % a
227
+ HAML
228
+ to raise_error(Hamlit::SyntaxError, 'Invalid tag: "% a".')
229
+ end
230
+
231
+ it 'rejects an invalid tag' do
232
+ expect { render_string(<<-HAML.unindent) }.
233
+ %.foo
234
+ HAML
235
+ to raise_error(Hamlit::SyntaxError, 'Invalid tag: "%.foo".')
236
+ end
237
+ end
222
238
  end
223
239
  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: 1.6.4
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun