beachio-hammer 0.1.0.pre7 → 0.1.0.pre9
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/Gemfile.lock +1 -1
- data/lib/hammer/tag_parser.rb +15 -3
- data/lib/hammer/version.rb +1 -1
- data/spec/path_resolution_spec.rb +9 -0
- 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: '07779bca29478e635f67821d004ba96905631011cb967e95e00a6d1e84487411'
|
|
4
|
+
data.tar.gz: bc4e18fc7474ced30a3a7870526f52aa0d686929a3e6acdc65cfd3c220210498
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e448896ed2855bc9ff9cdc3577c42e7a0f701ef4deae3e3caddeb692a9239b0cedfa1caa6f92c1be0556bc98912a0d1a7aa8f63ef4f5d9a7ad09d8ff6da9af6
|
|
7
|
+
data.tar.gz: 8dd7f8b90f6111c8dcf800ee8270948f32594566993355e07d243f48654253d6ee4c63ab0ba30dc35d00d02536cb5de64565c5f3009ecae7ef4aad6c0e61685a
|
data/Gemfile.lock
CHANGED
data/lib/hammer/tag_parser.rb
CHANGED
|
@@ -235,10 +235,14 @@ module Hammer
|
|
|
235
235
|
processed = array_data.map do |item|
|
|
236
236
|
item_content = template.dup
|
|
237
237
|
item_hash = item.is_a?(Hash) ? item.transform_keys(&:to_s) : { "value" => item.to_s }
|
|
238
|
+
# Resolve dotted paths (e.g. @post.category.name) before scalar @post.category
|
|
239
|
+
# substitution — relation fields are Hashes and value_to_string(Hash) is empty.
|
|
240
|
+
item_content = process_nested_properties(item_content, item_hash, item_name)
|
|
238
241
|
item_hash.each do |key, value|
|
|
242
|
+
next if value.is_a?(Hash) || value.is_a?(Array)
|
|
243
|
+
|
|
239
244
|
item_content.gsub!("@#{item_name}.#{key}", value_to_string(value))
|
|
240
245
|
end
|
|
241
|
-
item_content = process_nested_properties(item_content, item_hash, item_name)
|
|
242
246
|
item_content = process_conditionals_in_loop(item_content, item_hash, item_name)
|
|
243
247
|
process_helper_expressions_in_loop(item_content, item_hash, item_name)
|
|
244
248
|
end.join
|
|
@@ -439,8 +443,15 @@ module Hammer
|
|
|
439
443
|
end
|
|
440
444
|
|
|
441
445
|
def resolve_path_reference(ref)
|
|
446
|
+
fragment = ""
|
|
447
|
+
if ref.include?("#")
|
|
448
|
+
base, anchor = ref.split("#", 2)
|
|
449
|
+
ref = base
|
|
450
|
+
fragment = "##{anchor}" unless anchor.nil? || anchor.empty?
|
|
451
|
+
end
|
|
452
|
+
|
|
442
453
|
if ref == "/"
|
|
443
|
-
return root_relative_path
|
|
454
|
+
return "#{root_relative_path}#{fragment}"
|
|
444
455
|
end
|
|
445
456
|
|
|
446
457
|
preserve_slash = ref.end_with?("/")
|
|
@@ -462,7 +473,8 @@ module Hammer
|
|
|
462
473
|
|
|
463
474
|
@delegate&.warning(@current_file_path, "File not found: #{ref}") if paths.empty?
|
|
464
475
|
|
|
465
|
-
generate_context_aware_path(relative_path, preserve_trailing_slash: preserve_slash)
|
|
476
|
+
resolved = generate_context_aware_path(relative_path, preserve_trailing_slash: preserve_slash)
|
|
477
|
+
"#{resolved}#{fragment}"
|
|
466
478
|
end
|
|
467
479
|
|
|
468
480
|
def root_relative_path
|
data/lib/hammer/version.rb
CHANGED
|
@@ -24,6 +24,15 @@ RSpec.describe Hammer::TagParser do
|
|
|
24
24
|
expect(result).to include('href="../../"')
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
it "preserves URL fragments when resolving @path to a page" do
|
|
28
|
+
parser.current_file_path = "index.html"
|
|
29
|
+
content = '<a href="<!-- @path work/mixfit/#team -->">'
|
|
30
|
+
|
|
31
|
+
result = parser.send(:parse, content)
|
|
32
|
+
|
|
33
|
+
expect(result).to match(/href="[^"]*mixfit\/#team"/)
|
|
34
|
+
end
|
|
35
|
+
|
|
27
36
|
it "does not corrupt digits in image filenames when resolving @path" do
|
|
28
37
|
parser.current_file_path = "products/forge/index.html"
|
|
29
38
|
content = '<img src="<!-- @path assets/images/products/forge-2.jpg -->" />'
|