lib/theme_check/liquid_node.rb in theme-check-1.7.2 vs lib/theme_check/liquid_node.rb in theme-check-1.8.0

- old
+ new

@@ -72,10 +72,38 @@ def end_index position.end_index end + def start_token_index + return position.start_index if inside_liquid_tag? + position.start_index - (start_token.length + 1) + end + + def end_token_index + return position.end_index if inside_liquid_tag? + position.end_index + end_token.length + end + + def render_start_tag + "#{start_token} #{@value.raw}#{end_token}" + end + + def render_end_tag + "#{start_token} #{@value.block_delimiter} #{end_token}" + end + + def block_body_start_index + return unless block_tag? + block_regex.begin(:body) + end + + def block_body_end_index + return unless block_tag? + block_regex.end(:body) + end + # Literals are hard-coded values in the liquid file. def literal? @value.is_a?(String) || @value.is_a?(Integer) end @@ -181,9 +209,14 @@ output += "%}" if tag? output end private + + def block_regex + return unless block_tag? + /(?<start_token>#{render_start_tag})(?<body>.*)(?<end_token>#{render_end_tag})/m.match(source) + end def position @position ||= Position.new( markup, theme_file&.source,