haml 6.0.11-java → 6.0.12-java

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
  SHA256:
3
- metadata.gz: 31849c95695d5db575f824528a49044c948bd030c9716a38d94db197269079ce
4
- data.tar.gz: 931c560f376df2ba100ae8524e345807e990303fdb6b8cc8f6a8a37a3b761dd5
3
+ metadata.gz: cb8a21f15b84d6db83c10d326bd3016dbed2c304d6d3368ff8aa6d301ed1b552
4
+ data.tar.gz: 0b433e1f195f04713a6c18f8a61351ce47cb570f58278428fcbbd4db12fd5e54
5
5
  SHA512:
6
- metadata.gz: a064605dc7436fa9cb8bbb143c029cf37cc25c9c5ff2ece1d5225c4b0c5ef54f4314bc014f71550d66f26dd8a64ce800553642a94263488719d60856efcb6b74
7
- data.tar.gz: 8a61fafa65f148a3548feddc7e65a801ce75f08f1ac256a4a5e2bf1d7940ff6a6016b4b6d13d3c4228ab96e3980b63e07a9fcd3bcffcba2fcc7ac8253d3c49e3
6
+ metadata.gz: 1b9baad8b912705b985dae60151085c8d33a7771f7fac1e8bb9ba2a9476f213f1b1b123c5df23cc6663ac8a29605090c5471b6b59b98235d8c3cd548af4f270b
7
+ data.tar.gz: f37d30f29c49e6b8aa137c9727637956c1c68f17ab4e59795a0f9fb8999f8616052c5cba4dfee6680f4b459051f0b5a0a3fe10b98996e210d06c6da635007563
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 6.0.12
4
+
5
+ * Fix a whitespace removal with `>` and an `if`-`else` statement [#1114](https://github.com/haml/haml/issues/1114)
6
+
3
7
  ## 6.0.11
4
8
 
5
9
  * Fix a whitespace removal with `>` and an `if` statement [#1114](https://github.com/haml/haml/issues/1114)
@@ -6,6 +6,7 @@ module Haml
6
6
  class ChildrenCompiler
7
7
  def initialize
8
8
  @lineno = 1
9
+ @multi_flattener = Temple::Filters::MultiFlattener.new
9
10
  end
10
11
 
11
12
  def compile(node, &block)
@@ -89,15 +90,48 @@ module Haml
89
90
  end
90
91
 
91
92
  def rstrip_whitespace!(temple)
93
+ return if temple.size == 1
94
+
92
95
  case temple[0]
93
- when :multi, :block
96
+ when :multi
94
97
  case temple[-1][0]
95
- when :multi, :block
96
- rstrip_whitespace!(temple[-1])
97
98
  when :whitespace
98
99
  temple.delete_at(-1)
100
+ when :multi, :block
101
+ rstrip_whitespace!(temple[-1])
102
+ end
103
+ when :block
104
+ _block, code, exp = temple
105
+ if code.start_with?(/\s*if\s/)
106
+ # Remove [:whitespace] before `end`
107
+ exp.replace(@multi_flattener.call(exp))
108
+ rstrip_whitespace!(exp)
109
+
110
+ # Remove [:whitespace] before `else` if exists
111
+ else_index = find_else_index(exp)
112
+ if else_index
113
+ whitespace_index = else_index - 1
114
+ while exp[whitespace_index] == [:newline]
115
+ whitespace_index -= 1
116
+ end
117
+ if exp[whitespace_index] == [:whitespace]
118
+ exp.delete_at(whitespace_index)
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
124
+
125
+ def find_else_index(temple)
126
+ multi, *args = temple
127
+ return nil if multi != :multi
128
+
129
+ args.each_with_index do |arg, index|
130
+ if arg[0] == :code && arg[1].match?(/\A\s*else\s*\z/)
131
+ return index + 1
99
132
  end
100
133
  end
134
+ nil
101
135
  end
102
136
 
103
137
  def insert_whitespace?(node)
data/lib/haml/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Haml
3
- VERSION = '6.0.11'
3
+ VERSION = '6.0.12'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.11
4
+ version: 6.0.12
5
5
  platform: java
6
6
  authors:
7
7
  - Natalie Weizenbaum
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2022-11-26 00:00:00.000000000 Z
15
+ date: 2022-11-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  requirement: !ruby/object:Gem::Requirement