Skip to content

Instantly share code, notes, and snippets.

@savchukoleksii
Last active July 20, 2021 14:58
Show Gist options
  • Save savchukoleksii/072eeb68b2c6249e75e0af7bd79ff696 to your computer and use it in GitHub Desktop.
Save savchukoleksii/072eeb68b2c6249e75e0af7bd79ff696 to your computer and use it in GitHub Desktop.
{%- assign section_customizer_settings = "" -%}
{%- for setting in section.settings -%}
{%- capture setting_data -%}
"{{- setting -}}": {{- section.settings[setting] | json -}}
{%- endcapture -%}
{%- if section_customizer_settings != blank -%}
{%- assign section_customizer_settings = section_customizer_settings | append: "," -%}
{%- endif -%}
{%- assign section_customizer_settings = section_customizer_settings | append: setting_data -%}
{%- endfor -%}
{%- assign section_customizer_settings = "{" | append: section_customizer_settings | append: "}" -%}
{%- assign section_customizer_blocks = "" -%}
{%- for block in section.blocks -%}
{%- assign block_settings = "" -%}
{%- for setting in block.settings -%}
{%- capture setting_data -%}
"{{- setting -}}": {{- block.settings[setting] | json -}}
{%- endcapture -%}
{%- if block_settings != blank -%}
{%- assign block_settings = block_settings | append: "," -%}
{%- endif -%}
{%- assign block_settings = block_settings | append: setting_data -%}
{%- endfor -%}
{%- assign block_settings = "{" | append: block_settings | append: "}" -%}
{%- capture setting_data -%}
{
"id": {{- block.id | json -}},
"type": {{- block.type | json -}},
"shopify_attributes": {{- block.shopify_attributes | json -}},
"settings": {{- block_settings -}}
}
{%- endcapture -%}
{%- endfor-%}
{%- assign section_customizer_blocks = "[" | append: section_customizer_settings | append: "]" -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment