hamlit 1.6.4 → 1.6.5
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/doc/engine/old_attributes.md +8 -5
- data/doc/faml/engine/old_attributes.md +5 -2
- data/doc/haml/engine/old_attributes.md +4 -4
- data/lib/hamlit/attribute.rb +1 -1
- data/lib/hamlit/parsers/tag.rb +7 -2
- data/lib/hamlit/version.rb +1 -1
- data/spec/hamlit/engine/old_attributes_spec.rb +2 -0
- data/spec/hamlit/engine/text_spec.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5cc29adeedc23941351000259c916d89cdea442
|
|
4
|
+
data.tar.gz: affff05b7d78d2c7af5dd23a7c1d7ecd01e15bd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea281451bd2d83164bd6a6d8b40c129d8551d06ebc64403e2bcbe5c9f4777dc7c911b385ef7077107a5e05b325e1fbcd844729569b2db6f8d4217bc6bf480268
|
|
7
|
+
data.tar.gz: 906d0de6f993ffc61831c3660399a8186e8d17a89bb89f3fff9af07d46e90ccdad7575a90c4630cf172d09ae6dd01e4bcb577837672a7949866a4e4c3990b4e3
|
data/CHANGELOG.md
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
118
|
+
# [old\_attributes\_spec.rb:252](/spec/hamlit/engine/old_attributes_spec.rb#L252)
|
|
119
119
|
## Input
|
|
120
120
|
```haml
|
|
121
121
|
- title = { title: "'\"" }
|
data/lib/hamlit/attribute.rb
CHANGED
|
@@ -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]
|
data/lib/hamlit/parsers/tag.rb
CHANGED
|
@@ -15,8 +15,13 @@ module Hamlit
|
|
|
15
15
|
DEFAULT_TAG = 'div'
|
|
16
16
|
|
|
17
17
|
def parse_tag(scanner)
|
|
18
|
-
|
|
19
|
-
|
|
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)
|
data/lib/hamlit/version.rb
CHANGED
|
@@ -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<b>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
|