synvert-core 1.26.2 → 1.26.3

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: bd799296837ee0bf3c825c10cf317c7c010dbd52f397442b8e608cfc32a52478
4
- data.tar.gz: ee34f716844c96be497fd388457472f44f89c230cadb578ecfaabe374f870ae9
3
+ metadata.gz: 33af6c56062d411c6a6b22460889e1416975ce685fe1d8e8e86c73583ea8c3c3
4
+ data.tar.gz: fc14712ad5a4a95f4c97cfd7cf41dbd51973b43c9a24be9086baf321a626a92e
5
5
  SHA512:
6
- metadata.gz: 248baf6eec5579b51bf26927e2b6d11ee2e71f57ba79ee4d26ee1df1928afcefb19fc3fab2dc39b85061a608ff319559230206835bad117e613cb2168fae2fef
7
- data.tar.gz: 92374f7d7aa5f1a87d9b7413c78ccdcfbf88e68be0d418684633dfa44b86dd19b1e870d9f680280d72ad6b8ae1fe3a60a7ac2acf24ea8c31200990e22d578f49
6
+ metadata.gz: ee2aee51d031543fade41cf86d36d8f3704fac0d1bebaf8d146400a73d277352318216b40c4b2bd819e6cd3dbb865ed8dbac05c6e53800a6e7e993460e0d1b73
7
+ data.tar.gz: 2ea5ae0070defc84ed1e2a157af58c3beab37c04cdc4b18b3528a5339a69aa8a4a02f53515a0fc14381e996bf7374497dc376c408dc305de1552f0db35cf503f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.28.3 (2023-05-13)
4
+
5
+ * Fix haml and slim engine to support attribute and ruby evalidation in the same line
6
+ * Fix ruby block in multi lins in haml and slim
7
+
3
8
  ## 1.26.2 (2023-05-10)
4
9
 
5
10
  * Update `node_mutation` to 1.16.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.26.2)
4
+ synvert-core (1.26.3)
5
5
  activesupport (< 7.0.0)
6
6
  node_mutation (>= 1.16.0)
7
7
  node_query (>= 1.12.1)
@@ -69,6 +69,9 @@ module Synvert::Core
69
69
 
70
70
  while rest.rstrip.end_with?(',')
71
71
  rest = scanner.scan(/.*?(\z|\n)/)
72
+ if IF_KEYWORDS.include?(keyword) || rest =~ DO_BLOCK_REGEX
73
+ leading_spaces_counts << leading_spaces_count
74
+ end
72
75
  new_code << rest
73
76
  end
74
77
  end
@@ -85,6 +88,9 @@ module Synvert::Core
85
88
 
86
89
  while rest.rstrip.end_with?(',')
87
90
  rest = scanner.scan(/.*?(\z|\n)/)
91
+ if rest =~ DO_BLOCK_REGEX
92
+ leading_spaces_counts << leading_spaces_count
93
+ end
88
94
  new_code << rest
89
95
  end
90
96
  end
@@ -28,7 +28,7 @@ module Synvert::Core
28
28
  new_code << (WHITESPACE * scanner.matched.size)
29
29
  scan_matching_wrapper(scanner, new_code, '{', '}')
30
30
  if scanner.scan('=')
31
- new_code << WHITESPACE
31
+ new_code << ';'
32
32
  scan_ruby_expression(scanner, new_code, leading_spaces_counts, leading_spaces_count)
33
33
  else
34
34
  scan_ruby_interpolation_and_plain_text(scanner, new_code, leading_spaces_counts, leading_spaces_count)
@@ -33,7 +33,7 @@ module Synvert::Core
33
33
  end
34
34
  scan_attributes_between_whitespace(scanner, new_code)
35
35
  if scanner.scan(/ ?==?/) # it matches ruby expression " span= current_user.login"
36
- new_code << (WHITESPACE * scanner.matched.size)
36
+ new_code << (WHITESPACE * (scanner.matched.size - 1)) + ';'
37
37
  scan_ruby_expression(scanner, new_code, leading_spaces_counts, leading_spaces_count)
38
38
  else
39
39
  scan_ruby_interpolation_and_plain_text(scanner, new_code, leading_spaces_counts, leading_spaces_count)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.26.2'
5
+ VERSION = '1.26.3'
6
6
  end
7
7
  end
@@ -98,6 +98,14 @@ module Synvert::Core
98
98
  expect(encoded_source).to be_include '{:href=>"/posts", :data => {:author_id => 123, :category => 7}}'
99
99
  end
100
100
 
101
+ it 'encodes attributes with ruby evaluation' do
102
+ source = <<~EOS
103
+ %a{:href=>"/posts", :data => {:author_id => 123, :category => 7}}= current_user.name
104
+ EOS
105
+ encoded_source = Engine::Haml.encode(source)
106
+ expect(encoded_source).to be_include '{:href=>"/posts", :data => {:author_id => 123, :category => 7}}; current_user.name'
107
+ end
108
+
101
109
  it 'encodes class and ID' do
102
110
  source = <<~EOS
103
111
  %div#things
@@ -194,6 +202,17 @@ module Synvert::Core
194
202
  expect(encoded_source).not_to be_include 'See, I can count!'
195
203
  end
196
204
 
205
+ it 'encodes ruby block in multi lines' do
206
+ source = <<~EOS
207
+ = form_for(:document, builder: BootstrapForm,
208
+ html: {id: 'new_document_form', class: 'form-vertical'}) do |f|
209
+ EOS
210
+ encoded_source = Engine::Haml.encode(source)
211
+ expect(encoded_source).to be_include 'form_for'
212
+ expect(encoded_source).to be_include 'do |f|'
213
+ expect(encoded_source).to be_include 'end'
214
+ end
215
+
197
216
  it 'encodes ruby interpolation' do
198
217
  source = 'Look at #{h word} lack of backslash: \#{foo}'
199
218
  encoded_source = Engine::Haml.encode(source)
@@ -131,8 +131,8 @@ module Synvert::Core
131
131
  h2[id="tagline" class="small tagline"] = page_tagline
132
132
  EOS
133
133
  encoded_source = Engine::Slim.encode(source)
134
- expect(encoded_source).to be_include 'page_logo'
135
- expect(encoded_source).to be_include 'page_tagline'
134
+ expect(encoded_source).to be_include '; page_logo'
135
+ expect(encoded_source).to be_include '; page_tagline'
136
136
  expect(encoded_source).not_to be_include 'h1'
137
137
  expect(encoded_source).not_to be_include 'h2'
138
138
  expect(encoded_source).not_to be_include 'id'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.26.2
4
+ version: 1.26.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-10 00:00:00.000000000 Z
11
+ date: 2023-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport