Module: ThemeCheck::ShopifyLiquid::Tag

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

Instance Method Summary collapse

Instance Method Details

#end_labelsObject



15
16
17
18
19
# File 'lib/theme_check/shopify_liquid/tag.rb', line 15

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

#labelsObject



9
10
11
12
13
# File 'lib/theme_check/shopify_liquid/tag.rb', line 9

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

#liquid_tag_regex(tag) ⇒ Object



27
28
29
30
31
# File 'lib/theme_check/shopify_liquid/tag.rb', line 27

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



21
22
23
24
25
# File 'lib/theme_check/shopify_liquid/tag.rb', line 21

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