hamlit 1.4.5 → 1.4.6
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/lib/hamlit/parser.rb +4 -2
- data/lib/hamlit/parsers/multiline.rb +4 -0
- data/lib/hamlit/parsers/tag.rb +1 -2
- data/lib/hamlit/parsers/text.rb +3 -11
- data/lib/hamlit/version.rb +1 -1
- data/spec/hamlit/engine/script_spec.rb +9 -0
- data/spec/hamlit/engine/text_spec.rb +28 -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: 9a6fd40edd6056710c6fb7a7e571f287355eb797
|
4
|
+
data.tar.gz: afbad9c5994019cf52bfd0e304a07cfe8f6ec218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b71d35469d13442cfdf812ff0fca240f592e825c5b73f30fca91b064b4332b49eff366de7fa55055f7cad58b8e0d91a5790827eba7d76bea06fd66413be597d8
|
7
|
+
data.tar.gz: 56b2b3b77f0a8a8eade006c176196952934ffff5f7a29d8ea15547ab448879299b5c1b63d31d0875290e160370744c187885467f5c0a88cf04128b6d2f78f0b4
|
data/CHANGELOG.md
CHANGED
data/lib/hamlit/parser.rb
CHANGED
@@ -89,10 +89,12 @@ module Hamlit
|
|
89
89
|
return parse_script(scanner, force_escape: true)
|
90
90
|
elsif scanner.match?(/!!!/)
|
91
91
|
return parse_doctype(scanner)
|
92
|
+
elsif scanner.scan(/!( |==)/)
|
93
|
+
return parse_text(scanner, lstrip: true, escape: false)
|
92
94
|
elsif scanner.match?(/!=/)
|
93
95
|
return parse_script(scanner, disable_escape: true)
|
94
|
-
elsif scanner.
|
95
|
-
return
|
96
|
+
elsif scanner.scan(/==/)
|
97
|
+
return parse_text(scanner, lstrip: true)
|
96
98
|
elsif scanner.match?(/[.#](\Z|[^a-zA-Z0-9_-])/)
|
97
99
|
return parse_text(scanner)
|
98
100
|
end
|
@@ -5,6 +5,8 @@ module Hamlit
|
|
5
5
|
module Multiline
|
6
6
|
include Concerns::LineReader
|
7
7
|
|
8
|
+
SPACED_BLOCK_REGEXP = /do +\| *[^\|]+ *\|\Z/
|
9
|
+
|
8
10
|
def preprocess_multilines(template)
|
9
11
|
reset_lines(template.split("\n"))
|
10
12
|
result = []
|
@@ -30,6 +32,8 @@ module Hamlit
|
|
30
32
|
|
31
33
|
def end_with_pipe?(line)
|
32
34
|
return false unless line
|
35
|
+
return false if line =~ SPACED_BLOCK_REGEXP
|
36
|
+
|
33
37
|
line.strip =~ / \|\Z/
|
34
38
|
end
|
35
39
|
|
data/lib/hamlit/parsers/tag.rb
CHANGED
@@ -29,8 +29,7 @@ module Hamlit
|
|
29
29
|
elsif scanner.scan(/\//)
|
30
30
|
return ast
|
31
31
|
elsif scanner.rest.match(/[^ ]/)
|
32
|
-
scanner
|
33
|
-
ast << parse_text(scanner)
|
32
|
+
ast << parse_text(scanner, lstrip: true)
|
34
33
|
return ast
|
35
34
|
elsif next_indent <= @current_indent
|
36
35
|
return ast << [:multi]
|
data/lib/hamlit/parsers/text.rb
CHANGED
@@ -5,18 +5,10 @@ module Hamlit
|
|
5
5
|
module Text
|
6
6
|
include Concerns::Error
|
7
7
|
|
8
|
-
def parse_text(scanner)
|
9
|
-
ast = [:haml, :text]
|
10
|
-
ast << (scanner.scan(/.+/) || '')
|
11
|
-
ast
|
12
|
-
end
|
13
|
-
|
14
|
-
def parse_unescaped_text(scanner)
|
15
|
-
assert_scan!(scanner, /! /)
|
16
|
-
scanner.scan(/ +/)
|
17
|
-
|
8
|
+
def parse_text(scanner, lstrip: false, escape: true)
|
18
9
|
text = (scanner.scan(/.+/) || '')
|
19
|
-
|
10
|
+
text = text.lstrip if lstrip
|
11
|
+
[:haml, :text, text, escape]
|
20
12
|
end
|
21
13
|
end
|
22
14
|
end
|
data/lib/hamlit/version.rb
CHANGED
@@ -65,6 +65,15 @@ describe Hamlit::Engine do
|
|
65
65
|
HTML
|
66
66
|
end
|
67
67
|
|
68
|
+
it 'renders block and a variable with spaces' do
|
69
|
+
assert_render(<<-HAML, <<-HTML)
|
70
|
+
- 1.times do | i |
|
71
|
+
= i
|
72
|
+
HAML
|
73
|
+
0
|
74
|
+
HTML
|
75
|
+
end
|
76
|
+
|
68
77
|
it 'accepts a continuing script' do
|
69
78
|
assert_render(<<-HAML, <<-HTML)
|
70
79
|
- def foo(a, b); a + b; end
|
@@ -39,6 +39,34 @@ describe Hamlit::Engine do
|
|
39
39
|
HTML
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'renders == operator' do
|
43
|
+
assert_render(<<-'HAML', <<-HTML)
|
44
|
+
===
|
45
|
+
== =
|
46
|
+
== <a>
|
47
|
+
== #{'<a>'}
|
48
|
+
HAML
|
49
|
+
=
|
50
|
+
=
|
51
|
+
<a>
|
52
|
+
<a>
|
53
|
+
HTML
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'renders !== operator' do
|
57
|
+
assert_render(<<-'HAML', <<-HTML)
|
58
|
+
== #{'<a>'}
|
59
|
+
!== #{'<a>'}
|
60
|
+
!===
|
61
|
+
!== =
|
62
|
+
HAML
|
63
|
+
<a>
|
64
|
+
<a>
|
65
|
+
=
|
66
|
+
=
|
67
|
+
HTML
|
68
|
+
end
|
69
|
+
|
42
70
|
it 'leaves empty spaces after backslash' do
|
43
71
|
expect(render_string('\ a')).to eq(" a\n")
|
44
72
|
end
|