Module: ThemeCheck::ShopifyLiquid::Tag

Extended by:
Tag
Included in:
Tag
Defined in:
lib/theme_check/shopify_liquid/tag.rb

Constant Summary collapse

LABELS_NOT_IN_SOURCE_INDEX =
["elsif", "ifchanged", { "schema" => "endschema" }, "when"]

Instance Method Summary collapse

Instance Method Details

#end_labelsObject



17
18
19
20
21
# File 'lib/theme_check/shopify_liquid/tag.rb', line 17

def end_labels
  @end_labels ||= tags_file_contents
    .select { |x| x.is_a?(Hash) }
    .map { |x| x.values[0] }
end

#labelsObject



11
12
13
14
15
# File 'lib/theme_check/shopify_liquid/tag.rb', line 11

def labels
  @labels ||= tags_file_contents
    .map { |x| to_label(x) }
    .to_set
end

#liquid_tag_regex(tag) ⇒ Object



29
30
31
32
33
# File 'lib/theme_check/shopify_liquid/tag.rb', line 29

def liquid_tag_regex(tag)
  return unless labels.include?(tag)
  @tag_liquid_regexes ||= {}
  @tag_liquid_regexes[tag] ||= /^\s*#{tag}/m
end

#tag_regex(tag) ⇒ Object



23
24
25
26
27
# File 'lib/theme_check/shopify_liquid/tag.rb', line 23

def tag_regex(tag)
  return unless labels.include?(tag)
  @tag_regexes ||= {}
  @tag_regexes[tag] ||= /\A#{Liquid::TagStart}-?\s*#{tag}/m
end