Class: ThemeCheck::RequiredLayoutThemeObject
- Inherits:
-
LiquidCheck
- Object
- Check
- LiquidCheck
- ThemeCheck::RequiredLayoutThemeObject
- Defined in:
- lib/theme_check/checks/required_layout_theme_object.rb
Overview
Reports missing content_for_header and content_for_layout in theme.liquid
Constant Summary collapse
- LAYOUT_FILENAME =
"layout/theme"
Constants inherited from Check
Check::CATEGORIES, Check::SEVERITIES, Check::SEVERITY_VALUES
Instance Attribute Summary
Attributes inherited from Check
#ignored_patterns, #offenses, #options, #theme
Instance Method Summary collapse
- #after_document(node) ⇒ Object
-
#initialize ⇒ RequiredLayoutThemeObject
constructor
A new instance of RequiredLayoutThemeObject.
- #on_document(node) ⇒ Object
- #on_variable(node) ⇒ Object
Methods included from ChecksTracking
Methods included from ParsingHelpers
Methods inherited from Check
#==, #add_offense, all, can_disable, #can_disable?, categories, #categories, category, #code_name, doc, #doc, docs_url, #ignore!, #ignored?, #severity, severity, #severity=, #severity_value, severity_value, single_file, #single_file?, #to_s, #whole_theme?
Methods included from JsonHelpers
Constructor Details
#initialize ⇒ RequiredLayoutThemeObject
Returns a new instance of RequiredLayoutThemeObject.
11 12 13 14 |
# File 'lib/theme_check/checks/required_layout_theme_object.rb', line 11 def initialize @content_for_layout_found = false @content_for_header_found = false end |
Instance Method Details
#after_document(node) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/theme_check/checks/required_layout_theme_object.rb', line 27 def after_document(node) return unless node.template.name == LAYOUT_FILENAME add_missing_object_offense("content_for_layout") unless @content_for_layout_found add_missing_object_offense("content_for_header") unless @content_for_header_found end |
#on_document(node) ⇒ Object
16 17 18 |
# File 'lib/theme_check/checks/required_layout_theme_object.rb', line 16 def on_document(node) @layout_theme_node = node if node.template.name == LAYOUT_FILENAME end |
#on_variable(node) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/theme_check/checks/required_layout_theme_object.rb', line 20 def on_variable(node) return unless node.value.name.is_a?(Liquid::VariableLookup) @content_for_header_found ||= node.value.name.name == "content_for_header" @content_for_layout_found ||= node.value.name.name == "content_for_layout" end |