Debian Codegraph @

demo/kitchen-sink/docs/liquid.liquid

raw
1 There are a couple of different Liquid variations in circulation. This grammars supports
2 both the Standard and Shopify Liquid variations. The following examples can be found in full at:
3
4 Standard Variation: https://shopify.github.io/liquid
5 Shopify Variation: https://shopify.dev/docs/api/liquid
6
7 Liquid is an extraction from the e-commerce system Shopify.
8 Shopify powers many thousands of e-commerce stores which all call for unique designs.
9 For this we developed Liquid which allows our customers complete design freedom while
10 maintaining the integrity of our servers.
11
12 Liquid has been in production use since June 2006 and is now used by many other
13 hosted web applications.
14
15 It was developed for usage in Ruby on Rails web applications and integrates seamlessly
16 as a plugin but it also works excellently as a stand alone library.
17
18 Here's what it looks like:
19
20 <ul id="products">
21 {% for product in products %}
22 <li>
23 <h2>{{ product.title }}</h2>
24 Only {{ product.price | format_as_money }}
25
26 <p>{{ product.description | prettyprint | truncate: 200 }}</p>
27
28 </li>
29 {% endfor %}
30 </ul>
31
32
33 Some more features include:
34
35 <h2>Filters</h2>
36 <p> The word "tobi" in uppercase: {{ 'tobi' | upcase }} </p>
37 <p>The word "tobi" has {{ 'tobi' | size }} letters! </p>
38 <p>Change "Hello world" to "Hi world": {{ 'Hello world' | replace: 'Hello', 'Hi' }} </p>
39 <p>The date today is {{ 'now' | date: "%Y %b %d" }} </p>
40
41
42 <h2>If</h2>
43 <p>
44 {% if user.name == 'tobi' or user.name == 'marc' %}
45 hi marc or tobi
46 {% endif %}
47 </p>
48
49 <h2>Comments</h2>
50
51 {% # Line Comment %}
52
53 {% comment %}
54 Block Comment
55 {% endcomment %}
56
57 <h2>Case</h2>
58 <p>
59 {% case template %}
60 {% when 'index' %}
61 Welcome
62 {% when 'product' %}
63 {{ product.vendor | link_to_vendor }} / {{ product.title }}
64 {% else %}
65 {{ page_title }}
66 {% endcase %}
67 </p>
68
69
70 <h2>For Loops</h2>
71 <p>
72 {% for item in array %}
73 {{ item }}
74 {% endfor %}
75 </p>
76
77
78 <h2>Tables</h2>
79 <p>
80 {% tablerow item in items cols: 3 %}
81 {% if tablerowloop.col_first %}
82 First column: {{ item.variable }}
83 {% else %}
84 Different column: {{ item.variable }}
85 {% endif %}
86 {% endtablerow %}
87 </p>
88
89 <h2>Embedded Code Blocks</h2>
90
91 This support Shopify Liquid variation JSON schema code blocks
92
93 {% schema %}
94 {
95 "string": "bar",
96 "boolean": true,
97 "number": 100,
98 "object": {
99 "array": [100, false, "string", {}, [] ]
100 }
101 }
102 {% endschema %}
103
104 This support Shopify Liquid variation Stylesheet and Style code blocks
105
106 {% style %}
107 .class {
108 font-size: 10px; /* comment */
109 }
110 {% endstyle %}
111
112 {% stylesheet %}
113 .class {
114 font-size: 10px; /* comment */
115 }
116 {% endstylesheet %}
117
118 This support Shopify Liquid variation JavaScript code blocks
119
120 {% javascript %}
121
122 function foo (param) {
123
124 return 'something' // comment
125 }
126
127 {% endjavascript %}