Class: ShopifyCLI::Theme::File::JsonTemplateNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/theme/file.rb

Instance Method Summary collapse

Instance Method Details

#visit_document(value) ⇒ Object



128
129
130
# File 'lib/shopify_cli/theme/file.rb', line 128

def visit_document(value)
  visit_hash(value["sections"])
end

#visit_hash(hash) ⇒ Object



132
133
134
135
136
137
# File 'lib/shopify_cli/theme/file.rb', line 132

def visit_hash(hash)
  return unless hash.is_a?(Hash)
  hash.each do |_, value|
    visit_value(value)
  end
end

#visit_value(value) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/shopify_cli/theme/file.rb', line 139

def visit_value(value)
  # Reinsert settings to force the same ordering as in the backend
  settings = value.delete("settings") || {}
  value["settings"] = settings

  visit_hash(value["blocks"])
end