mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-26 13:45:15 -07:00
fix(docs): unify playground pane padding and hold output on errors
Match editor inset to the output panel, drop Prism from output preview, keep the last render while typing invalid template/context, and refresh the README demo GIF.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# LiquidJS
|
# LiquidJS
|
||||||
|
|
||||||
A simple, expressive [Shopify Liquid][shopify/liquid] template engine for JavaScript — compatible with Jekyll and GitHub Pages dialects, runs in Node.js, the browser (UMD/ESM), and the CLI via `npx liquidjs`, and ships with TypeScript definitions. Extend it with custom tags, filters, and [plugins][plugins]; optional `memoryLimit`, `renderLimit`, and `ownPropertyOnly` help harden untrusted templates (not a sandbox — see the [security model][security-model]).
|
A simple, expressive [Shopify Liquid][shopify/liquid] template engine for JavaScript — Jekyll and GitHub Pages compatible, for Node.js, browsers, and the CLI, with TypeScript support.
|
||||||
|
|
||||||
[](https://www.npmjs.org/package/liquidjs)
|
[](https://www.npmjs.org/package/liquidjs)
|
||||||
[](https://www.npmjs.org/package/liquidjs)
|
[](https://www.npmjs.org/package/liquidjs)
|
||||||
@@ -244,10 +244,8 @@ Want to contribute? see [Contribution Guidelines][contribution]. Thanks goes to
|
|||||||
[MIT](LICENSE) © [Jun Yang](https://github.com/harttle)
|
[MIT](LICENSE) © [Jun Yang](https://github.com/harttle)
|
||||||
|
|
||||||
[shopify/liquid]: https://shopify.github.io/liquid/
|
[shopify/liquid]: https://shopify.github.io/liquid/
|
||||||
[plugins]: https://liquidjs.com/tutorials/plugins.html#Plugin-List
|
|
||||||
[setup]: https://liquidjs.com/tutorials/setup.html
|
[setup]: https://liquidjs.com/tutorials/setup.html
|
||||||
[doc]: https://liquidjs.com
|
[doc]: https://liquidjs.com
|
||||||
[github]: https://github.com/harttle/liquidjs
|
[github]: https://github.com/harttle/liquidjs
|
||||||
[oc]: https://opencollective.com/liquidjs/
|
[oc]: https://opencollective.com/liquidjs/
|
||||||
[contribution]: https://liquidjs.com/tutorials/contribution-guidelines.html
|
[contribution]: https://liquidjs.com/tutorials/contribution-guidelines.html
|
||||||
[security-model]: https://liquidjs.com/tutorials/security-model.html
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 36 KiB |
@@ -4,8 +4,6 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src-min/mode-liquid.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src-min/mode-liquid.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src-min/mode-json.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/src-min/mode-json.js"></script>
|
||||||
<script>ace.config.set('basePath', 'https://cdn.jsdelivr.net/npm/[email protected]/src-min/');</script>
|
<script>ace.config.set('basePath', 'https://cdn.jsdelivr.net/npm/[email protected]/src-min/');</script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-markup.min.js"></script>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ js('js/main') }}
|
{{ js('js/main') }}
|
||||||
|
|||||||
@@ -121,40 +121,3 @@ pre
|
|||||||
color: var(--highlight-bash-command)
|
color: var(--highlight-bash-command)
|
||||||
.operator
|
.operator
|
||||||
color: var(--highlight-purple)
|
color: var(--highlight-purple)
|
||||||
|
|
||||||
// Prism (playground output) — uses palette tokens for light/dark
|
|
||||||
code[class*="language-"]
|
|
||||||
color: var(--highlight-foreground)
|
|
||||||
.token.comment,
|
|
||||||
.token.prolog,
|
|
||||||
.token.doctype,
|
|
||||||
.token.cdata
|
|
||||||
color: var(--highlight-comment)
|
|
||||||
.token.punctuation
|
|
||||||
color: var(--highlight-foreground)
|
|
||||||
.token.property,
|
|
||||||
.token.tag,
|
|
||||||
.token.boolean,
|
|
||||||
.token.number,
|
|
||||||
.token.constant,
|
|
||||||
.token.symbol,
|
|
||||||
.token.deleted
|
|
||||||
color: var(--highlight-red)
|
|
||||||
.token.attr-name,
|
|
||||||
.token.selector,
|
|
||||||
.token.string,
|
|
||||||
.token.char,
|
|
||||||
.token.builtin,
|
|
||||||
.token.inserted
|
|
||||||
color: var(--highlight-green)
|
|
||||||
.token.attr-value,
|
|
||||||
.token.regex,
|
|
||||||
.token.variable
|
|
||||||
color: var(--highlight-blue)
|
|
||||||
.token.operator,
|
|
||||||
.token.entity,
|
|
||||||
.token.url
|
|
||||||
color: var(--highlight-aqua)
|
|
||||||
.token.atrule,
|
|
||||||
.token.keyword
|
|
||||||
color: var(--highlight-purple)
|
|
||||||
|
|||||||
+28
-3
@@ -1,6 +1,7 @@
|
|||||||
#playground
|
#playground
|
||||||
--playground-gap: 12px
|
--playground-gap: 12px
|
||||||
--playground-radius: 10px
|
--playground-radius: 10px
|
||||||
|
--playground-inset: 16px
|
||||||
background: var(--color-content-bg)
|
background: var(--color-content-bg)
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
box-shadow: var(--panel-shadow)
|
box-shadow: var(--panel-shadow)
|
||||||
@@ -124,7 +125,7 @@
|
|||||||
gap: 10px
|
gap: 10px
|
||||||
flex-shrink: 0
|
flex-shrink: 0
|
||||||
height: 36px
|
height: 36px
|
||||||
padding: 0 12px
|
padding: 0 var(--playground-inset)
|
||||||
border-bottom: 1px solid var(--code-border)
|
border-bottom: 1px solid var(--code-border)
|
||||||
@media mq-mobile
|
@media mq-mobile
|
||||||
height: 32px
|
height: 32px
|
||||||
@@ -151,9 +152,32 @@
|
|||||||
min-width: 0
|
min-width: 0
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
overflow: visible
|
overflow: hidden
|
||||||
background: var(--highlight-background)
|
background: var(--highlight-background)
|
||||||
|
|
||||||
|
.area-tpl .pane-body,
|
||||||
|
.area-data .pane-body
|
||||||
|
padding: var(--playground-inset)
|
||||||
|
box-sizing: border-box
|
||||||
|
@media mq-mobile
|
||||||
|
padding: 12px
|
||||||
|
|
||||||
|
.area-tpl .ace_gutter,
|
||||||
|
.area-data .ace_gutter
|
||||||
|
display: none !important
|
||||||
|
width: 0 !important
|
||||||
|
min-width: 0 !important
|
||||||
|
|
||||||
|
.area-tpl .ace_editor,
|
||||||
|
.area-data .ace_editor,
|
||||||
|
.area-tpl .ace_scroller,
|
||||||
|
.area-data .ace_scroller,
|
||||||
|
.area-tpl .ace_content,
|
||||||
|
.area-data .ace_content,
|
||||||
|
.area-tpl .ace_text-layer,
|
||||||
|
.area-data .ace_text-layer
|
||||||
|
background: transparent !important
|
||||||
|
|
||||||
.editor
|
.editor
|
||||||
flex: 1 1 auto
|
flex: 1 1 auto
|
||||||
min-height: 0
|
min-height: 0
|
||||||
@@ -175,7 +199,7 @@
|
|||||||
min-height: 100%
|
min-height: 100%
|
||||||
width: 100%
|
width: 100%
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
padding: 16px
|
padding: var(--playground-inset)
|
||||||
border: none
|
border: none
|
||||||
box-shadow: none
|
box-shadow: none
|
||||||
border-radius: 0
|
border-radius: 0
|
||||||
@@ -194,6 +218,7 @@
|
|||||||
font-family: font-mono
|
font-family: font-mono
|
||||||
font-size: 14px
|
font-size: 14px
|
||||||
line-height: 1.55
|
line-height: 1.55
|
||||||
|
color: var(--highlight-foreground)
|
||||||
background: transparent
|
background: transparent
|
||||||
padding: 0
|
padding: 0
|
||||||
white-space: inherit
|
white-space: inherit
|
||||||
|
|||||||
Vendored
+8
-7
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// playground
|
// playground
|
||||||
/* global liquidjs, ace, Prism */
|
/* global liquidjs, ace */
|
||||||
if (!/\/playground(?:\.html)?$/.test(location.pathname)) return;
|
if (!/\/playground(?:\.html)?$/.test(location.pathname)) return;
|
||||||
updateVersion(liquidjs.version);
|
updateVersion(liquidjs.version);
|
||||||
const engine = new liquidjs.Liquid({
|
const engine = new liquidjs.Liquid({
|
||||||
@@ -86,6 +86,8 @@
|
|||||||
|
|
||||||
function applyEditorTheme(editor) {
|
function applyEditorTheme(editor) {
|
||||||
editor.setTheme(getEditorTheme());
|
editor.setTheme(getEditorTheme());
|
||||||
|
editor.renderer.setPadding(0);
|
||||||
|
editor.container.style.background = 'transparent';
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEditor(id, lang) {
|
function createEditor(id, lang) {
|
||||||
@@ -103,7 +105,10 @@
|
|||||||
});
|
});
|
||||||
editor.getSession().setMode('ace/mode/' + lang);
|
editor.getSession().setMode('ace/mode/' + lang);
|
||||||
editor.renderer.setShowGutter(false);
|
editor.renderer.setShowGutter(false);
|
||||||
editor.renderer.setScrollMargin(8, 8, 0, 0);
|
if (editor.renderer.$gutter) {
|
||||||
|
editor.renderer.$gutter.style.display = 'none';
|
||||||
|
}
|
||||||
|
editor.renderer.setScrollMargin(0, 0, 0, 0);
|
||||||
bindClipboard(editor);
|
bindClipboard(editor);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
@@ -163,10 +168,6 @@
|
|||||||
function setPreview (value) {
|
function setPreview (value) {
|
||||||
previewValue = value
|
previewValue = value
|
||||||
previewCode.textContent = value
|
previewCode.textContent = value
|
||||||
if (window.Prism) {
|
|
||||||
delete previewCode.dataset.highlighted
|
|
||||||
window.Prism.highlightElement(previewCode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update() {
|
async function update() {
|
||||||
@@ -177,7 +178,7 @@
|
|||||||
const html = await engine.parseAndRender(tpl, JSON.parse(data));
|
const html = await engine.parseAndRender(tpl, JSON.parse(data));
|
||||||
setPreview(html);
|
setPreview(html);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setPreview(err.stack);
|
// keep last successful output while template or context is invalid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user