Last active
March 5, 2026 01:43
-
-
Save jbasoo/08fa237b6df11bf1233c141e22eba67b to your computer and use it in GitHub Desktop.
Convert SVG files to a Shopify Liquid Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # USAGE: svg-to-liquid.sh iconSourcePath icons.liquid | |
| # Add the icons.liquid file to your theme snippets then output the icon using {% render 'icons', icon: 'icon-name' %} | |
| echo "Converting SVGs to Shopify Liquid Snippet" | |
| liquid=$'{% case icon %}\n'; | |
| for svg in $1/*.svg; do | |
| file="$(basename $svg)"; | |
| name="${file%.*}" | |
| liquid+=" {% when '"${name}"' %}"$'\n' | |
| liquid+=" $(cat $svg)" | |
| liquid+=$'\n' | |
| done | |
| liquid+="{% endcase %}"; | |
| echo "${liquid}" > $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment