super-slim 3.6.2 → 3.6.3
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 +11 -1
- data/README.md +5 -5
- data/lib/super_slim/compiler.rb +24 -2
- data/lib/super_slim/parser.rb +5 -1
- data/lib/super_slim/version.rb +1 -1
- data/lib/super_slim.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bdda53d82fc2a91f77cf19258e1ee428e89b765df89a9e91e93af3517a6c2f0f
|
|
4
|
+
data.tar.gz: 6998c577d2553c9ab39efc167c5bdbe576eecc891a959ec31d90b3ffc822c2bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2adce8b7a0578e7488852e04e267fd8ff964021f59719602be4e018583b1faae79a264c8f165148352ff1879c303957d582917c1d030eaa5d086d4404e505da4
|
|
7
|
+
data.tar.gz: 6d40b5b0e0d8e68655c74237d82cf89f9d9afb0fd2053bf89cfb987a53d670b403de410055a711b640fa4f431529afc3e753fadbbe3fe09a36dc1a7fa5ca4bf4
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [3.6.3] — 2026-11-21
|
|
6
|
+
|
|
7
|
+
One fix: a line break inside an interpolation of a quoted attribute no longer shifts the lines that follow.
|
|
8
|
+
|
|
9
|
+
**Fixed**
|
|
10
|
+
- A quoted attribute whose `#{…}` spans lines, such as `p title="#{t(:title,` then `count: 2)}"` on the next line,
|
|
11
|
+
no longer moves every later line one line down per break in backtraces, `__LINE__` and compile errors. The
|
|
12
|
+
attributes of a `ruby:` or `markdown:` block keep their lines too.
|
|
13
|
+
|
|
5
14
|
## [3.6.2] — 2026-11-20
|
|
6
15
|
|
|
7
16
|
Template errors found while compiling now point at their template line, in Rails too.
|
|
@@ -321,7 +330,8 @@ renders what Slim 5 renders with `format: :html, sort_attrs: false`, byte for by
|
|
|
321
330
|
- Ruby 3.3 or later, every Ruby still maintained, Rails 8.0 or 8.1 for the railtie, and strscan 3.1.1 or later,
|
|
322
331
|
newer than the one Ruby 3.3 ships.
|
|
323
332
|
|
|
324
|
-
[Unreleased]: https://github.com/levups/super-slim/compare/v3.6.
|
|
333
|
+
[Unreleased]: https://github.com/levups/super-slim/compare/v3.6.3...HEAD
|
|
334
|
+
[3.6.3]: https://github.com/levups/super-slim/compare/v3.6.2...v3.6.3
|
|
325
335
|
[3.6.2]: https://github.com/levups/super-slim/compare/v3.6.1...v3.6.2
|
|
326
336
|
[3.6.1]: https://github.com/levups/super-slim/compare/v3.6.0...v3.6.1
|
|
327
337
|
[3.6.0]: https://github.com/levups/super-slim/compare/v3.5.0...v3.6.0
|
data/README.md
CHANGED
|
@@ -461,11 +461,11 @@ bin/release minor --dry-run # shows the notes and the changes, writes nothing
|
|
|
461
461
|
bin/release minor # or patch, major, or an exact version such as 1.2.0
|
|
462
462
|
```
|
|
463
463
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
464
|
+
`main` takes no direct push, so `bin/release` dates the notes and bumps the version on a `release/vX.Y.Z` branch,
|
|
465
|
+
opens a pull request that merges itself once CI is green, and waits for it (`bin/release --wait X.Y.Z` if you
|
|
466
|
+
stopped it). The merge starts the Release workflow, which waits for a maintainer's approval, tags the merge commit
|
|
467
|
+
`vX.Y.Z`, publishes the gem to RubyGems through trusted publishing and creates the GitHub release with the notes
|
|
468
|
+
and the `.gem`.
|
|
469
469
|
|
|
470
470
|
## License
|
|
471
471
|
|
data/lib/super_slim/compiler.rb
CHANGED
|
@@ -106,6 +106,13 @@ module SuperSlim
|
|
|
106
106
|
parts
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
+
# The line breaks inside the text's interpolations, which its compiled code keeps.
|
|
110
|
+
def self.interpolation_newlines(text)
|
|
111
|
+
return 0 unless text.include?("\n") && text.include?('#{')
|
|
112
|
+
|
|
113
|
+
interpolation_parts(text).sum { |kind, code| (kind == :dynamic) ? code.count("\n") : 0 }
|
|
114
|
+
end
|
|
115
|
+
|
|
109
116
|
private
|
|
110
117
|
|
|
111
118
|
def compile_children(nodes)
|
|
@@ -225,8 +232,8 @@ module SuperSlim
|
|
|
225
232
|
next if attribute.name == "class"
|
|
226
233
|
if seen_names.key?(attribute.name)
|
|
227
234
|
# Reported on the last line of the attributes, like the tag's compiled code, which follows their code.
|
|
228
|
-
|
|
229
|
-
compile_error!("Multiple #{attribute.name} attributes specified", lines_ahead:
|
|
235
|
+
lines_ahead = attributes.sum { |other| code_newlines(other) }
|
|
236
|
+
compile_error!("Multiple #{attribute.name} attributes specified", lines_ahead:)
|
|
230
237
|
end
|
|
231
238
|
|
|
232
239
|
seen_names[attribute.name] = true
|
|
@@ -385,6 +392,11 @@ module SuperSlim
|
|
|
385
392
|
end
|
|
386
393
|
|
|
387
394
|
def compile_embedded(embedded)
|
|
395
|
+
case embedded.engine
|
|
396
|
+
when "ruby", "markdown"
|
|
397
|
+
# Their attributes are dropped, and with them the lines their interpolations go on to.
|
|
398
|
+
@code << ("\n" * embedded.attributes.sum { code_newlines(_1) })
|
|
399
|
+
end
|
|
388
400
|
case embedded.engine
|
|
389
401
|
when "ruby" then compile_ruby(embedded.children)
|
|
390
402
|
when "javascript" then compile_tag(Tag.new("script", embedded.attributes, [TextBlock.new(embedded.children)]))
|
|
@@ -439,6 +451,16 @@ module SuperSlim
|
|
|
439
451
|
end
|
|
440
452
|
end
|
|
441
453
|
|
|
454
|
+
# The lines an attribute's Ruby code goes on to: a code attribute's, and those of a quoted attribute's
|
|
455
|
+
# interpolations, which the parser leaves to the code.
|
|
456
|
+
def code_newlines(attribute)
|
|
457
|
+
case attribute
|
|
458
|
+
when CodeAttribute then attribute.code.count("\n")
|
|
459
|
+
when QuotedAttribute then Compiler.interpolation_newlines(attribute.text)
|
|
460
|
+
else 0
|
|
461
|
+
end
|
|
462
|
+
end
|
|
463
|
+
|
|
442
464
|
# The compiled code keeps each template line on its own line, so the newlines written so far give the line of
|
|
443
465
|
# the node being compiled: no node carries its line, which would cost every template line. Code not written
|
|
444
466
|
# yet may still hold `lines_ahead` of them.
|
data/lib/super_slim/parser.rb
CHANGED
|
@@ -629,6 +629,7 @@ module SuperSlim
|
|
|
629
629
|
first = source_offset if @outline
|
|
630
630
|
value = +""
|
|
631
631
|
depth = 0
|
|
632
|
+
breaks = 0
|
|
632
633
|
quote_byte = quote.ord
|
|
633
634
|
|
|
634
635
|
until depth == 0 && @scanner.peek_byte == quote_byte
|
|
@@ -636,7 +637,7 @@ module SuperSlim
|
|
|
636
637
|
# Unlike a stripped continuation line, a line read whole keeps its trailing whitespace in the value.
|
|
637
638
|
@outline[@lineno].text = true if @outline && @scanner.eos? && @scanner.string.equal?(@line)
|
|
638
639
|
value << (@scanner.eos? ? "\n" : " ")
|
|
639
|
-
|
|
640
|
+
breaks += 1
|
|
640
641
|
expect_next_line
|
|
641
642
|
elsif (chunk = @scanner.scan(QUOTED_CHUNK_BY_QUOTE[quote]))
|
|
642
643
|
value << chunk
|
|
@@ -648,6 +649,9 @@ module SuperSlim
|
|
|
648
649
|
end
|
|
649
650
|
end
|
|
650
651
|
|
|
652
|
+
# A break inside an interpolation is already a line of the compiled code, which keeps it: only the others get
|
|
653
|
+
# a newline node.
|
|
654
|
+
(breaks - Compiler.interpolation_newlines(value)).times { @stacks.last << NEWLINE } if breaks > 0
|
|
651
655
|
record_ruby(:text, first, source_offset) if @outline
|
|
652
656
|
@scanner.pos += 1
|
|
653
657
|
value
|
data/lib/super_slim/version.rb
CHANGED
data/lib/super_slim.rb
CHANGED
|
@@ -70,8 +70,9 @@ module SuperSlim
|
|
|
70
70
|
# Located like the parser's errors, its backtrace starting at the template line, which Rails reports.
|
|
71
71
|
def compile_syntax_error(exception, source, file)
|
|
72
72
|
lineno = exception.lineno
|
|
73
|
-
# The source parsed, so it is valid UTF-8 whatever its encoding says. A
|
|
74
|
-
# more lines than its template
|
|
73
|
+
# The source parsed, so it is valid UTF-8 whatever its encoding says. A count past the end guards against
|
|
74
|
+
# compiled code taking more lines than its template, which no construct is known to do: the error still
|
|
75
|
+
# raises, without that line.
|
|
75
76
|
line = String.new(Parser.split_lines(source.b)[lineno - 1].to_s, encoding: Encoding::UTF_8)
|
|
76
77
|
line = line.delete_prefix("") if lineno == 1
|
|
77
78
|
error = SyntaxError.new(exception.message, file, line, lineno, line[/\A[ \t]*/].size)
|