Module: LiquidXlsx::Validation::BlockBoundary

Defined in:
lib/liquid_xlsx/validation/block_boundary.rb

Overview

Whether a merged range crosses the boundary of a structural block.

A merge that starts outside a {% for %} and ends inside it cannot be cloned per iteration, so the renderer refuses such templates. The rule lives here because two callers need it and they must agree: the renderer (which only sees blocks it actually executes) and the validator (which sees every block in the AST, executed or not).

Class Method Summary collapse

Class Method Details

.crosses?(merge_start, merge_end, block_start, block_end) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/liquid_xlsx/validation/block_boundary.rb', line 15

def crosses?(merge_start, merge_end, block_start, block_end)
  # Merge entirely above or below the block
  return false if merge_end < block_start || merge_start > block_end

  # Merge strictly inside the block body (between the tag rows)
  return false if merge_start > block_start && merge_end < block_end

  # Merge entirely on a single structural tag row (it is consumed with it)
  return false if merge_start == merge_end && (merge_start == block_start || merge_start == block_end)

  # Any other overlap = crossing (including merges that swallow a tag row)
  true
end