tina4ruby 3.10.2 → 3.10.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/lib/tina4/template.rb +44 -8
- data/lib/tina4/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: cfe8b7f49e17e2a703725d23ce90791acca6e078dc7747a0eebaf97091121330
|
|
4
|
+
data.tar.gz: a6a2e0c2e48b69e332d6bc0358929a141f91919b19062639259d7c51cb390a39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24a17f01e57ffda9278e80e0451e54f82111921c1066f21ab30436391e05c475c613c6948824f4fe8d94ddc17f39796240ca47f6ecda8bfe166f805b54335b22
|
|
7
|
+
data.tar.gz: 2b0c24c5dbef5d4f4d2c3e5337f7dce2bc1f8a89a90cbb149484fe375914cf8465e604ccc6f30e264a78922e4132ad27f7f4d7189e7f589450cf3baa5361c0f1
|
data/lib/tina4/template.rb
CHANGED
|
@@ -431,24 +431,60 @@ module Tina4
|
|
|
431
431
|
value
|
|
432
432
|
end
|
|
433
433
|
|
|
434
|
-
# Split expression on dots,
|
|
434
|
+
# Split expression on dots, respecting quotes, parentheses and brackets.
|
|
435
|
+
# Dots inside quoted strings or nested parens/brackets are NOT separators.
|
|
436
|
+
# Bracket access like foo["bar"] is emitted as a separate part.
|
|
435
437
|
def split_dot_parts(expr)
|
|
436
438
|
parts = []
|
|
437
439
|
current = +""
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
paren_depth = 0
|
|
441
|
+
bracket_depth = 0
|
|
442
|
+
in_quote = nil
|
|
443
|
+
|
|
444
|
+
i = 0
|
|
445
|
+
chars = expr.chars
|
|
446
|
+
while i < chars.length
|
|
447
|
+
ch = chars[i]
|
|
448
|
+
|
|
449
|
+
if in_quote
|
|
450
|
+
current << ch
|
|
451
|
+
# End quote only when matching unescaped closer
|
|
452
|
+
in_quote = nil if ch == in_quote && (i == 0 || chars[i - 1] != "\\")
|
|
453
|
+
elsif ch == '"' || ch == "'"
|
|
454
|
+
in_quote = ch
|
|
455
|
+
current << ch
|
|
456
|
+
elsif ch == "("
|
|
457
|
+
paren_depth += 1
|
|
442
458
|
current << ch
|
|
443
459
|
elsif ch == ")"
|
|
444
|
-
|
|
460
|
+
paren_depth -= 1
|
|
461
|
+
current << ch
|
|
462
|
+
elsif ch == "[" && paren_depth == 0
|
|
463
|
+
if bracket_depth == 0 && !current.empty?
|
|
464
|
+
# Start of bracket access on an existing part -- split here
|
|
465
|
+
parts << current
|
|
466
|
+
current = +""
|
|
467
|
+
end
|
|
468
|
+
bracket_depth += 1
|
|
445
469
|
current << ch
|
|
446
|
-
elsif ch == "
|
|
447
|
-
|
|
470
|
+
elsif ch == "]"
|
|
471
|
+
bracket_depth -= 1
|
|
472
|
+
current << ch
|
|
473
|
+
if bracket_depth == 0 && paren_depth == 0
|
|
474
|
+
# End of top-level bracket access -- emit as its own part
|
|
475
|
+
parts << current
|
|
476
|
+
current = +""
|
|
477
|
+
# Skip a trailing dot that merely chains the next segment
|
|
478
|
+
i += 1 if i + 1 < chars.length && chars[i + 1] == "."
|
|
479
|
+
end
|
|
480
|
+
elsif ch == "." && paren_depth == 0 && bracket_depth == 0
|
|
481
|
+
parts << current unless current.empty?
|
|
448
482
|
current = +""
|
|
449
483
|
else
|
|
450
484
|
current << ch
|
|
451
485
|
end
|
|
486
|
+
|
|
487
|
+
i += 1
|
|
452
488
|
end
|
|
453
489
|
parts << current unless current.empty?
|
|
454
490
|
parts
|
data/lib/tina4/version.rb
CHANGED