hamli 0.4.0 → 0.5.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 +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/hamli/parser.rb +36 -7
- data/lib/hamli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0371e95f3c87b4519036500b8ff6b5a7de3a91f9509f05240a9a23d53105ff
|
4
|
+
data.tar.gz: f96c2b0b84ad2d546433934ebe40e6973effe559896e0bacda88a0d769e462fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60c15036fe01fc5c4716cf49f8969dca86055628c42ba7c299a66de3102f08b7520d1c296f58b032840bfd925b5fcefaae068add96cc9f7d9370a68667d27c1e
|
7
|
+
data.tar.gz: a6c1a3d3b777ef1fd46f4928d2c045f57051169d84d2643050e1b917cb49cc0db0b9a20f9dee049a9fed8a1ad172ed74bae20fa4b94ab6616405d66d814970b2
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/hamli/parser.rb
CHANGED
@@ -44,6 +44,10 @@ module Hamli
|
|
44
44
|
parse_control_line
|
45
45
|
elsif @scanner.match?(/=/)
|
46
46
|
parse_output_line
|
47
|
+
elsif @scanner.match?(/&=/)
|
48
|
+
parse_escaped_output_line
|
49
|
+
elsif @scanner.match?(/!=/)
|
50
|
+
parse_non_escaped_output_line
|
47
51
|
else
|
48
52
|
parse_text_line
|
49
53
|
end
|
@@ -138,7 +142,7 @@ module Hamli
|
|
138
142
|
content = parse_broken_lines
|
139
143
|
end_ = @scanner.charpos
|
140
144
|
block = [:multi]
|
141
|
-
tag << [:hamli, :position, begin_, end_, [:hamli, :output, content, block]]
|
145
|
+
tag << [:hamli, :position, begin_, end_, [:hamli, :output, false, content, block]]
|
142
146
|
@stacks << block
|
143
147
|
elsif @scanner.scan(%r{[ \t]*/[ \t]*})
|
144
148
|
# Does nothing.
|
@@ -406,24 +410,51 @@ module Hamli
|
|
406
410
|
[:hamli, :interpolate, begin_, end_, value]
|
407
411
|
end
|
408
412
|
|
413
|
+
# Parse escaped output line part.
|
414
|
+
# e.g. != abc
|
415
|
+
# ^^^^^^
|
416
|
+
# @todo Support :escape_html option on this parser, then rethink about escaping.
|
417
|
+
def parse_non_escaped_output_line
|
418
|
+
@scanner.pos += 1
|
419
|
+
parse_output_line
|
420
|
+
end
|
421
|
+
|
422
|
+
# Parse escaped output line part.
|
423
|
+
# e.g. &= abc
|
424
|
+
# ^^^^^^
|
425
|
+
def parse_escaped_output_line
|
426
|
+
@scanner.pos += 2
|
427
|
+
@scanner.scan(/[ \t]*/)
|
428
|
+
parse_ruby_line(escaped: true, name: :output)
|
429
|
+
end
|
430
|
+
|
409
431
|
# Parse output line part.
|
410
432
|
# e.g. = abc
|
411
433
|
# ^^^^^
|
412
434
|
def parse_output_line
|
413
|
-
|
435
|
+
@scanner.pos += 1
|
436
|
+
@scanner.scan(/[ \t]*/)
|
437
|
+
parse_ruby_line(escaped: false, name: :output)
|
414
438
|
end
|
415
439
|
|
416
440
|
# Parse control line part.
|
417
441
|
# e.g. - abc
|
418
442
|
# ^^^^^
|
419
|
-
def parse_control_line
|
443
|
+
def parse_control_line
|
420
444
|
@scanner.pos += 1
|
445
|
+
@scanner.scan(/[ \t]*/)
|
446
|
+
parse_ruby_line(escaped: false, name: :control)
|
447
|
+
end
|
448
|
+
|
449
|
+
# @param [Boolean] escaped
|
450
|
+
# @param [Symbol] name
|
451
|
+
def parse_ruby_line(escaped:, name:)
|
421
452
|
@scanner.scan(/[ \t]*/)
|
422
453
|
block = [:multi]
|
423
454
|
begin_ = @scanner.charpos
|
424
455
|
content = parse_broken_lines
|
425
456
|
end_ = @scanner.charpos
|
426
|
-
@stacks.last << [:hamli, :position, begin_, end_, [:hamli, name, content, block]]
|
457
|
+
@stacks.last << [:hamli, :position, begin_, end_, [:hamli, name, escaped, content, block]]
|
427
458
|
@stacks << block
|
428
459
|
end
|
429
460
|
|
@@ -439,9 +470,7 @@ module Hamli
|
|
439
470
|
result << @scanner.scan(/[^\r\n]*/)
|
440
471
|
end
|
441
472
|
lines = result.lines
|
442
|
-
if lines.length >= 2 && lines.all? { |line| line.end_with?("|\n") }
|
443
|
-
result.gsub!(/\|$/, '')
|
444
|
-
end
|
473
|
+
result.gsub!(/\|$/, '') if lines.length >= 2 && lines.all? { |line| line.end_with?("|\n") }
|
445
474
|
result.delete_suffix("\n")
|
446
475
|
end
|
447
476
|
|
data/lib/hamli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|