haml 6.0.10-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: 44554f3aa7da10cf2fe950258a176343ad27560a0569b722543640e81eb61fb7
4
- data.tar.gz: 9f43b1fcb6441016d93dbb0f2800d2bb54e645882468e20f2d69a1fefdc41e20
3
+ metadata.gz: cb8a21f15b84d6db83c10d326bd3016dbed2c304d6d3368ff8aa6d301ed1b552
4
+ data.tar.gz: 0b433e1f195f04713a6c18f8a61351ce47cb570f58278428fcbbd4db12fd5e54
5
5
  SHA512:
6
- metadata.gz: 808daff72a629634ff341be63fd4dde6a99c3e782004d9118a53f043cfd358fd1cf54ab3319780e9e247f38288b5be5b0cd551a1f0fbbd070360858c5823dc54
7
- data.tar.gz: 3c4789806d1386544a5fb17e56b396ce77da1f65582a824dde1c2b2c9940c7fd50e64dcbeadccfdfbdc54dc7f3c2f344b1fe3b1474b75d86e1bbaa88011e18f4
6
+ metadata.gz: 1b9baad8b912705b985dae60151085c8d33a7771f7fac1e8bb9ba2a9476f213f1b1b123c5df23cc6663ac8a29605090c5471b6b59b98235d8c3cd548af4f270b
7
+ data.tar.gz: f37d30f29c49e6b8aa137c9727637956c1c68f17ab4e59795a0f9fb8999f8616052c5cba4dfee6680f4b459051f0b5a0a3fe10b98996e210d06c6da635007563
data/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
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
+
7
+ ## 6.0.11
8
+
9
+ * Fix a whitespace removal with `>` and an `if` statement [#1114](https://github.com/haml/haml/issues/1114)
10
+
3
11
  ## 6.0.10
4
12
 
5
- * Evaluate :erb filter in the template context
13
+ * Evaluate :erb filter in the template context like Haml 5
6
14
 
7
15
  ## 6.0.9
8
16
 
@@ -95,6 +103,7 @@ Released on September 21, 2022
95
103
  * `-` script lines no longer support capturing. Only `=` lines are supported to yield a nested block.
96
104
  * Overriding `data` attributes with another falsy `data-*` attribute that has the same name
97
105
  is no longer supported. [#1105](https://github.com/haml/haml/issues/1105)
106
+ * :erb filter is not executed in the template context (fixed in 6.0.10)
98
107
 
99
108
  ## 5.2.2
100
109
 
data/REFERENCE.md CHANGED
@@ -338,20 +338,19 @@ will render as:
338
338
  <a> tag is so old links to here still work. -->
339
339
  <a id="html5_custom_data_attributes" style="border:0;"></a>
340
340
 
341
- #### Prefixed Attributes
341
+ #### Data Attributes
342
342
 
343
343
  HTML5 allows for adding
344
344
  [custom non-visible data attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
345
345
  to elements using attribute names beginning with `data-`. The
346
346
  [Accessible Rich Internet Applications](http://www.w3.org/WAI/intro/aria)
347
- specification makes use of attributes beginning with `aria-`. There are also
348
- frameworks that use non-standard attributes with a common prefix.
347
+ specification makes use of attributes beginning with `aria-`.
349
348
 
350
349
  Haml can help generate collections of attributes that share a prefix like
351
- these. Any entry in an attribute hash that has a Hash as its value is expanded
352
- into a series of attributes, one for each key/value pair in the hash, with the
353
- attribute name formed by joining the “parent” key name to the key name with a
354
- hyphen.
350
+ these. Any entry in an `data` or `aria` attribute hash that has a Hash as its
351
+ value is expanded into a series of attributes, one for each key/value pair in
352
+ the hash, with the attribute name formed by joining the “parent” key name to
353
+ the key name with a hyphen. This works only for `data` or `aria`.
355
354
 
356
355
  For example:
357
356
 
@@ -6,21 +6,22 @@ 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)
12
13
  temple = [:multi]
13
14
  return temple if node.children.empty?
14
15
 
15
- temple << :whitespace if prepend_whitespace?(node)
16
+ temple << [:whitespace] if prepend_whitespace?(node)
16
17
  node.children.each do |n|
17
18
  rstrip_whitespace!(temple) if nuke_prev_whitespace?(n)
18
19
  insert_newlines!(temple, n)
19
20
  temple << moving_lineno(n) { block.call(n) }
20
- temple << :whitespace if insert_whitespace?(n)
21
+ temple << [:whitespace] if insert_whitespace?(n)
21
22
  end
22
23
  rstrip_whitespace!(temple) if nuke_inner_whitespace?(node)
23
- confirm_whitespace(temple)
24
+ temple
24
25
  end
25
26
 
26
27
  private
@@ -56,17 +57,6 @@ module Haml
56
57
  temple
57
58
  end
58
59
 
59
- def confirm_whitespace(temple)
60
- temple.map do |exp|
61
- case exp
62
- when :whitespace
63
- [:static, "\n"]
64
- else
65
- exp
66
- end
67
- end
68
- end
69
-
70
60
  def prepend_whitespace?(node)
71
61
  return false unless %i[comment tag].include?(node.type)
72
62
  !nuke_inner_whitespace?(node)
@@ -100,9 +90,48 @@ module Haml
100
90
  end
101
91
 
102
92
  def rstrip_whitespace!(temple)
103
- if temple[-1] == :whitespace
104
- temple.delete_at(-1)
93
+ return if temple.size == 1
94
+
95
+ case temple[0]
96
+ when :multi
97
+ case temple[-1][0]
98
+ when :whitespace
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
132
+ end
105
133
  end
134
+ nil
106
135
  end
107
136
 
108
137
  def insert_whitespace?(node)
data/lib/haml/engine.rb CHANGED
@@ -8,6 +8,7 @@ require 'haml/escapable'
8
8
  require 'haml/force_escapable'
9
9
  require 'haml/dynamic_merger'
10
10
  require 'haml/ambles'
11
+ require 'haml/whitespace'
11
12
 
12
13
  module Haml
13
14
  class Engine < Temple::Engine
@@ -36,6 +37,7 @@ module Haml
36
37
  filter :ControlFlow
37
38
  use Ambles
38
39
  filter :MultiFlattener
40
+ use Whitespace
39
41
  filter :StaticMerger
40
42
  use DynamicMerger
41
43
  use :Generator, -> { options[:generator] }
data/lib/haml/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Haml
3
- VERSION = '6.0.10'
3
+ VERSION = '6.0.12'
4
4
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Whitespace < Temple::Filter
4
+ def on_whitespace
5
+ [:static, "\n"]
6
+ end
7
+ end
8
+ 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.10
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-10 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
@@ -333,6 +333,7 @@ files:
333
333
  - lib/haml/temple_line_counter.rb
334
334
  - lib/haml/util.rb
335
335
  - lib/haml/version.rb
336
+ - lib/haml/whitespace.rb
336
337
  homepage: https://haml.info
337
338
  licenses:
338
339
  - MIT
@@ -352,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
353
  - !ruby/object:Gem::Version
353
354
  version: '0'
354
355
  requirements: []
355
- rubygems_version: 3.2.29
356
+ rubygems_version: 3.2.33
356
357
  signing_key:
357
358
  specification_version: 4
358
359
  summary: An elegant, structured (X)HTML/XML templating engine.