forked from Shopify/prettier-plugin-liquid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandalone-demo.html
More file actions
69 lines (62 loc) · 2.1 KB
/
standalone-demo.html
File metadata and controls
69 lines (62 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<script src="file:///Users/charles/src/github.com/Shopify/prettier-plugin-liquid/node_modules/prettier/standalone.js"></script>
<script src="file:///Users/charles/src/github.com/Shopify/prettier-plugin-liquid/standalone.js"></script>
<title>Prettier Liquid Plugin</title>
<!--
You may use this file to test the standalone build and make sure everything works in a browser.
All you need to do is to open this file from your terminal with your browser.
```bash
# macOS
$ open standalone-demo.html
# linux
$ xdg-open standalone-demo.html
```
-->
<style>
textarea {
width: 100ex;
height: 100ex;
}
#stderr {
width: 200ex;
height: 30ex;
}
</style>
</head>
<body>
<textarea id="input" placeholder="Unformatted input">
<ul>{% for el in col %}<li class="{% cycle 'odd', 'even' %}" id="el-{{ el.index }}">{{ el.image }}</li>{% endfor %}</ul>
<ul class="container">
{% for el in col %}<li class="{% cycle 'odd', 'even' %}" id="something" data-prop="some value">
<div class="item-container"> <label>{{ el.value }}</label>
{{ el.featured_image | image_url | image_tag }}
</div>
</li> {% endfor %}
</ul>
</textarea>
<textarea id="output" placeholder="Prettified output" readonly></textarea>
<textarea id="stderr" placeholder="Error output" readonly></textarea>
<script>
function format() {
try {
output.value = prettier.format(input.value, {
plugins: [prettierPluginLiquid],
parser: 'liquid-html',
});
stderr.value = '';
} catch (error) {
stderr.value = error.stack || error;
}
}
function onKeyup(e) {
if (e.ctrlKey && event.key === 'f') {
input.value = output.value;
}
}
format();
input.oninput = format;
input.addEventListener('keyup', onKeyup)
</script>
</body>