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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f49550d59c10cbcb9b8ed9dae068082d5962abd833fcf2b6b039d07ce409b5e
4
- data.tar.gz: 4e04f20a894021945d2366a00a4b4239404541d139d60ed99c93c49afff767e5
3
+ metadata.gz: '07779bca29478e635f67821d004ba96905631011cb967e95e00a6d1e84487411'
4
+ data.tar.gz: bc4e18fc7474ced30a3a7870526f52aa0d686929a3e6acdc65cfd3c220210498
5
5
  SHA512:
6
- metadata.gz: 69c67662fc6d413a3af72e8873ad96345e8e363a87fac6657c1c10385239ab195201805c2e9d1784beae717316f15e9835ba81f1483e39f43b8028c971d03ab4
7
- data.tar.gz: 0efecd32fde11e6c6b6be017f427554cd7d57c11ad633d766c8b61be499b660cf7f61928e25dbcfd53db52cfe1ed765016c0ab0a5aa0d71a13503b921ed4f029
6
+ metadata.gz: 4e448896ed2855bc9ff9cdc3577c42e7a0f701ef4deae3e3caddeb692a9239b0cedfa1caa6f92c1be0556bc98912a0d1a7aa8f63ef4f5d9a7ad09d8ff6da9af6
7
+ data.tar.gz: 8dd7f8b90f6111c8dcf800ee8270948f32594566993355e07d243f48654253d6ee4c63ab0ba30dc35d00d02536cb5de64565c5f3009ecae7ef4aad6c0e61685a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beachio-hammer (0.1.0.pre6)
4
+ beachio-hammer (0.1.0.pre9)
5
5
  json (~> 2.7)
6
6
 
7
7
  GEM
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hammer
4
- VERSION = "0.1.0.pre7"
4
+ VERSION = "0.1.0.pre9"
5
5
  end
@@ -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 -->" />'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beachio-hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre7
4
+ version: 0.1.0.pre9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beach.io