hamlit 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +0 -1
- data/lib/hamlit/parsers/script.rb +16 -5
- data/lib/hamlit/version.rb +1 -1
- data/spec/hamlit/engine/silent_script_spec.rb +31 -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: 5175b4fea185d08238f003ae8669fe7747418b7e
|
4
|
+
data.tar.gz: 304e17d39d4cc0a6f7c04f0688f882d8375e5969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a45f5ebd7c99d9cd79b9651e409390cfac808b3c6cd87de51150dc86a613bf274be9183ba8328f4f8fc1af983337663641b0d784db7339074a692aecacf298fe
|
7
|
+
data.tar.gz: 064d03cfc93d24e066b6efadc24a73e422deb1a845542fb5dfe7890c1df362bcb1cbd522560258d1c86e78c185adb64e62be27df0bf4ca3fa2b7c220c400f303
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -85,7 +85,6 @@ to optimize performance such as string interpolation.
|
|
85
85
|
Currently there are some important incompatibilities that should be fixed.
|
86
86
|
|
87
87
|
- Remove falsy attributes [#2](https://github.com/k0kubun/hamlit/issues/2)
|
88
|
-
- Escape attribute values [#10](https://github.com/k0kubun/hamlit/issues/10)
|
89
88
|
|
90
89
|
## License
|
91
90
|
|
@@ -48,14 +48,19 @@ module Hamlit
|
|
48
48
|
return [:multi]
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
code = scan_code(scanner)
|
52
|
+
ast = [:multi, [:code, code]]
|
52
53
|
unless has_block?
|
53
|
-
|
54
|
+
if internal_statement?(code) && !statement_continuing?
|
55
|
+
ast << [:code, 'end']
|
56
|
+
end
|
54
57
|
return ast
|
55
58
|
end
|
56
59
|
|
57
60
|
ast += with_indented { parse_lines }
|
58
|
-
|
61
|
+
unless statement_continuing?
|
62
|
+
ast << [:code, 'end']
|
63
|
+
end
|
59
64
|
ast
|
60
65
|
end
|
61
66
|
|
@@ -93,12 +98,18 @@ module Hamlit
|
|
93
98
|
next_indent == @current_indent + 1
|
94
99
|
end
|
95
100
|
|
96
|
-
def
|
101
|
+
def statement_continuing?
|
102
|
+
same_indent?(next_line) && internal_statement?(next_line, silent_script: true)
|
103
|
+
end
|
104
|
+
|
105
|
+
def internal_statement?(line, silent_script: false)
|
97
106
|
return false unless line
|
98
107
|
|
99
108
|
scanner = StringScanner.new(line)
|
100
109
|
scanner.scan(/ +/)
|
101
|
-
|
110
|
+
if silent_script
|
111
|
+
return false unless scanner.scan(/-/)
|
112
|
+
end
|
102
113
|
|
103
114
|
scanner.scan(/ +/)
|
104
115
|
statement = scanner.scan(/[^ ]+/)
|
data/lib/hamlit/version.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
describe Hamlit::Engine do
|
2
2
|
describe 'silent script' do
|
3
|
+
it 'renders nothing' do
|
4
|
+
assert_render(<<-HAML, <<-HTML)
|
5
|
+
- nil
|
6
|
+
- 3
|
7
|
+
- 'foo'
|
8
|
+
HAML
|
9
|
+
HTML
|
10
|
+
end
|
11
|
+
|
3
12
|
it 'renders silent script' do
|
4
13
|
assert_render(<<-HAML, <<-HTML)
|
5
14
|
- foo = 3
|
@@ -67,6 +76,17 @@ describe Hamlit::Engine do
|
|
67
76
|
HTML
|
68
77
|
end
|
69
78
|
|
79
|
+
it 'renders empty elsif statement' do
|
80
|
+
assert_render(<<-'HAML', <<-HTML)
|
81
|
+
%span
|
82
|
+
- if false
|
83
|
+
- elsif false
|
84
|
+
HAML
|
85
|
+
<span>
|
86
|
+
</span>
|
87
|
+
HTML
|
88
|
+
end
|
89
|
+
|
70
90
|
it 'renders empty else statement' do
|
71
91
|
assert_render(<<-'HAML', <<-HTML)
|
72
92
|
%span
|
@@ -79,6 +99,17 @@ describe Hamlit::Engine do
|
|
79
99
|
HTML
|
80
100
|
end
|
81
101
|
|
102
|
+
it 'renders empty when statement' do
|
103
|
+
assert_render(<<-'HAML', <<-HTML)
|
104
|
+
%span
|
105
|
+
- case
|
106
|
+
- when false
|
107
|
+
HAML
|
108
|
+
<span>
|
109
|
+
</span>
|
110
|
+
HTML
|
111
|
+
end
|
112
|
+
|
82
113
|
it 'accept if inside if-else' do
|
83
114
|
assert_render(<<-'HAML', <<-HTML)
|
84
115
|
- if false
|