Created
December 24, 2019 19:28
-
-
Save james2doyle/dfd5af3251151fbfceb8d52b84d54538 to your computer and use it in GitHub Desktop.
An example of most of the things you can do in Liquid (Shopify). Used for building syntax highlighting
This file contains 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
Hello {{ 'tobi' | upcase }} | |
Hello tobi has {{ 'tobi' | size }} letters! | |
Hello {{ '*tobi*' | textilize | upcase }} | |
Hello {{ 'now' | date: "%Y %h" }} | |
{% if string contains 'hello' %} | |
string includes 'hello' | |
{% endif %} | |
{% for item in collection reversed %} {{item}} {% endfor %} | |
{% for i in (1..item.quantity) %} | |
{{ i }} | |
{% endfor %} | |
{% cycle 'one', 'two', 'three' %} | |
{% case template %} | |
{% when 'product' %} | |
{{ product.vendor | link_to_vendor }} / {{ product.title }} | |
{% else %} | |
{{page_title}} | |
{% endcase %} | |
{% liquid | |
echo 'sup?' %} | |
{% for item in items %} | |
{{ item }} | |
{% endfor %} | |
{% if freestyle %} | |
<p>Freestyle!</p> | |
{% endif %} | |
{% render 'something', variable: value %} | |
{% capture attribute_name %} | |
{{ item.title | handleize }}-{{ i }}-color | |
{% endcapture %} | |
{% raw %} | |
You can see this is not highlighted the same as {{ before | escape }} | |
{% endraw %} | |
{% schema %} | |
{ | |
"name": "Slideshow", | |
"settings": [ | |
{ | |
"id": "header", | |
"type": "text", | |
"label": "Header", | |
"default": "Hello world" | |
} | |
] | |
} | |
{% endschema %} | |
{% stylesheet %} | |
body { | |
color: white; | |
background-color: black; | |
} | |
{% endstylesheet %} | |
{% stylesheet 'scss' %} | |
body { | |
color: rgba(#fff, 0.2); | |
p { | |
margin: 0; | |
} | |
} | |
{% endstylesheet %} | |
{% javascript %} | |
const item = ['value', 1, false, null]; | |
item.map(i => i.toLowerCase()); | |
{% endjavascript %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment