← back to Dw Theme Boost Fix
snippets/utility.id.liquid
35 lines
{%- comment -%}
Id component
Accepts:
- section {section} - The section object
- block {block} - The block object
- index {number} - The index of the item
- name {string} - The name of the item
{%- endcomment -%}
{%- liquid
assign hyphen_separator = '-'
assign comma_separator = ','
capture id
if section != empty
echo section.id | prepend: comma_separator
endif
if block != blank
echo block.id | prepend: comma_separator
endif
if index != blank
echo index | prepend: comma_separator
endif
if name != blank
echo name | prepend: comma_separator
endif
endcapture
echo id | remove_first: comma_separator | split: comma_separator | join: hyphen_separator
-%}