Sha256: 9dbedec5223f583c3100bb25a5f05c47959fc9eebc21f0fde271dd7bc452a63a

Contents?: true

Size: 750 Bytes

Versions: 8

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  # Reports missing include/render/section template
  class MissingTemplate < LiquidCheck
    severity :suggestion
    category :liquid
    doc docs_url(__FILE__)
    single_file false

    def on_include(node)
      template = node.value.template_name_expr
      if template.is_a?(String)
        unless theme["snippets/#{template}"]
          add_offense("'snippets/#{template}.liquid' is not found", node: node)
        end
      end
    end
    alias_method :on_render, :on_include

    def on_section(node)
      template = node.value.section_name
      unless theme["sections/#{template}"]
        add_offense("'sections/#{template}.liquid' is not found", node: node)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
theme-check-1.2.0 lib/theme_check/checks/missing_template.rb
theme-check-1.1.0 lib/theme_check/checks/missing_template.rb
theme-check-1.0.0 lib/theme_check/checks/missing_template.rb
theme-check-0.10.2 lib/theme_check/checks/missing_template.rb
theme-check-0.10.1 lib/theme_check/checks/missing_template.rb
theme-check-0.10.0 lib/theme_check/checks/missing_template.rb
theme-check-0.9.1 lib/theme_check/checks/missing_template.rb
theme-check-0.9.0 lib/theme_check/checks/missing_template.rb