hamlit 1.4.5 → 1.4.6

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: 7de4f077471615790e1d0d4993e8fe0926ef84be
4
- data.tar.gz: b404e0b74b3a0857287424f22d530a5923eaa2f8
3
+ metadata.gz: 9a6fd40edd6056710c6fb7a7e571f287355eb797
4
+ data.tar.gz: afbad9c5994019cf52bfd0e304a07cfe8f6ec218
5
5
  SHA512:
6
- metadata.gz: f53a569a02a7aa2163559e29793f3a3890e1c6aff8f69e64864a296f738d770c99dc75196cc76643ac8bd209ada3887d916b2660ae63b97c0b7853c43424fcca
7
- data.tar.gz: a21d15241aef3b22a3419ac27561b2b020abb342cb5a01357efa2451dea4f06419a35d22a03379b6b47941b513ed98efbb822f3e9f3d6d7712aca32b04a709cd
6
+ metadata.gz: b71d35469d13442cfdf812ff0fca240f592e825c5b73f30fca91b064b4332b49eff366de7fa55055f7cad58b8e0d91a5790827eba7d76bea06fd66413be597d8
7
+ data.tar.gz: 56b2b3b77f0a8a8eade006c176196952934ffff5f7a29d8ea15547ab448879299b5c1b63d31d0875290e160370744c187885467f5c0a88cf04128b6d2f78f0b4
@@ -1,3 +1,8 @@
1
+ ## v1.4.6
2
+
3
+ - Support `!==`, `==` operator
4
+ - Avoid regarding spaced block as multiline
5
+
1
6
  ## v1.4.5
2
7
 
3
8
  - Support Ruby 2.0 and 2.1 for v1.4.4
@@ -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.match?(/! /)
95
- return parse_unescaped_text(scanner)
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
 
@@ -29,8 +29,7 @@ module Hamlit
29
29
  elsif scanner.scan(/\//)
30
30
  return ast
31
31
  elsif scanner.rest.match(/[^ ]/)
32
- scanner.scan(/ +/)
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]
@@ -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
- [:haml, :text, text, false]
10
+ text = text.lstrip if lstrip
11
+ [:haml, :text, text, escape]
20
12
  end
21
13
  end
22
14
  end
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = "1.4.5"
2
+ VERSION = "1.4.6"
3
3
  end
@@ -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
+ &lt;a&gt;
53
+ HTML
54
+ end
55
+
56
+ it 'renders !== operator' do
57
+ assert_render(<<-'HAML', <<-HTML)
58
+ == #{'<a>'}
59
+ !== #{'<a>'}
60
+ !===
61
+ !== =
62
+ HAML
63
+ &lt;a&gt;
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
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.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun