hamli 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/lib/hamli/filters/base.rb +2 -3
- data/lib/hamli/parser.rb +18 -5
- data/lib/hamli/version.rb +1 -1
- 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: 9f1faa1d3b9fa40c999ab475131a1cdf13a0cf97ad348b57a4d3fcbd2028e915
|
4
|
+
data.tar.gz: 33b020dd8ee73741bc3e262e48c0cab0e7d7be24eb1df90deecd322c6ae4237f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad5489d23376861eecd2b6de81ef2c9e9fd97cd57a81cc0679a59ae7e7500a4c4ddeba8831281f02c2e110657aaccf7751c89f5497f2dfc8c153daf86e17082
|
7
|
+
data.tar.gz: eceab6eadc445020e237eaa39f8b34a4b9007cc261327dc011ec97e00420532d51fd237c1614bc830874aad87cad520a3642dda41cb518dc1f1cc7f8303d9d9a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.4.0 - 2022-01-26
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Add :file option for better error report.
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Fix error from parse_text_block on some case.
|
14
|
+
- Fix filter bug on :text node.
|
15
|
+
- Fix parse_interpolate_line bug.
|
16
|
+
- Fix haml comment parser bug.
|
17
|
+
- Fix pipe multi-line handling.
|
18
|
+
|
5
19
|
## 0.3.0 - 2022-01-26
|
6
20
|
|
7
21
|
### Added
|
data/Gemfile.lock
CHANGED
data/lib/hamli/filters/base.rb
CHANGED
@@ -14,11 +14,10 @@ module Hamli
|
|
14
14
|
[:hamli, :position, begin_, end_, compile(expression)]
|
15
15
|
end
|
16
16
|
|
17
|
-
# @param [String] type
|
18
17
|
# @param [Array] expression
|
19
18
|
# @return [Array]
|
20
|
-
def on_hamli_text(
|
21
|
-
[:hamli, :text,
|
19
|
+
def on_hamli_text(expression)
|
20
|
+
[:hamli, :text, compile(expression)]
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
data/lib/hamli/parser.rb
CHANGED
@@ -4,6 +4,15 @@ require 'temple'
|
|
4
4
|
|
5
5
|
module Hamli
|
6
6
|
class Parser < ::Temple::Parser
|
7
|
+
define_options(
|
8
|
+
:file
|
9
|
+
)
|
10
|
+
|
11
|
+
def initialize(_options = {})
|
12
|
+
super
|
13
|
+
@file_path = options[:file] || '(__TEMPLATE__)'
|
14
|
+
end
|
15
|
+
|
7
16
|
# @param [String] source Haml template source.
|
8
17
|
# @return [Array]
|
9
18
|
def call(source)
|
@@ -351,8 +360,9 @@ module Hamli
|
|
351
360
|
# ^^^^^^
|
352
361
|
def parse_haml_comment_line
|
353
362
|
@scanner.pos += 2
|
363
|
+
@scanner.scan(/[^\r\n]*/)
|
354
364
|
while !@scanner.eos? && (@scanner.match?(/[ \t]*(?=\r|$)/) || peek_indent > @indents.last)
|
355
|
-
@scanner.
|
365
|
+
@scanner.scan(/[^\r\n]*/)
|
356
366
|
parse_line_ending
|
357
367
|
end
|
358
368
|
end
|
@@ -387,7 +397,7 @@ module Hamli
|
|
387
397
|
|
388
398
|
# @return [Array, nil]
|
389
399
|
def parse_interpolate_line
|
390
|
-
return unless @scanner.match?(/[^\r\n]
|
400
|
+
return unless @scanner.match?(/[^\r\n]+/)
|
391
401
|
|
392
402
|
begin_ = @scanner.charpos
|
393
403
|
value = @scanner.matched
|
@@ -425,11 +435,14 @@ module Hamli
|
|
425
435
|
while result.end_with?(',') || result.end_with?('|')
|
426
436
|
syntax_error!(Errors::UnexpectedEosError) unless @scanner.scan(/\r?\n/)
|
427
437
|
|
428
|
-
result.delete_suffix('|')
|
429
438
|
result << "\n"
|
430
439
|
result << @scanner.scan(/[^\r\n]*/)
|
431
440
|
end
|
432
|
-
result
|
441
|
+
lines = result.lines
|
442
|
+
if lines.length >= 2 && lines.all? { |line| line.end_with?("|\n") }
|
443
|
+
result.gsub!(/\|$/, '')
|
444
|
+
end
|
445
|
+
result.delete_suffix("\n")
|
433
446
|
end
|
434
447
|
|
435
448
|
# @param [Class] syntax_error_class A child class of Hamli::Errors::HamlSyntaxError.
|
@@ -446,7 +459,7 @@ module Hamli
|
|
446
459
|
|
447
460
|
# @return [Integer]
|
448
461
|
def indent_from_last_match
|
449
|
-
@scanner.matched.chars.map do |char|
|
462
|
+
(@scanner.matched || '').chars.map do |char|
|
450
463
|
case char
|
451
464
|
when "\t"
|
452
465
|
4
|
data/lib/hamli/version.rb
CHANGED