mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
Deploying to gh-pages from @ harttle/liquidjs@33009bb988 🚀
This commit is contained in:
@@ -115,7 +115,7 @@ engine<span class="token punctuation">.</span><span class="token function">regis
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="register-filters-tags.html" class="article-footer-prev" title="注册标签/过滤器"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="parse-parameters.html" class="article-footer-next" title="参数解析"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -124,7 +124,7 @@ engine<span class="token punctuation">.</span><span class="token function">rende
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="use-in-expressjs.html" class="article-footer-prev" title="Express.js 中使用"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="register-filters-tags.html" class="article-footer-next" title="注册标签/过滤器"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -110,7 +110,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="differences.html" class="article-footer-prev" title="与 Shopify/liquid 的不同"><i class="icon-chevron-left"></i><span>上一页</span></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -93,7 +93,20 @@
|
||||
|
||||
</header>
|
||||
<div class="article-content" itemprop="articleBody">
|
||||
<p><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/Shopify/liquid">Shopify/liquid</a> 中的所有标签和过滤器 LiquidJS 都支持,但不包括 Shopify 主题中业务逻辑相关的标签和过滤器(如果你在找这些标签可以参考 <a href="./plugins.html#插件列表">插件列表</a>,也欢迎把你的插件添加到列表中)。尽管原则上我们尽力兼容于 Shopify/liquid,但仍然存在一些区别:</p>
|
||||
<h2 id="兼容性" class="article-heading"><a href="#兼容性" class="headerlink" title="兼容性"></a>兼容性<a class="article-anchor" href="#兼容性" aria-hidden="true"></a></h2><p>LiquidJS 一直很重视兼容于 Ruby 版本的 Liquid。Liquid 模板语言最初由 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/Shopify/liquid">Ruby 实现</a>,用于 Shopify,Jekyll 以及 Github Pages,它是 Ruby 里最流行的模板引擎之一。因此由很多人用 LiquidJS 来渲染他们的 Shopify 主题和 Jekyll 站点。</p>
|
||||
<p>所以“兼容”意味着让这些开发者有很好的使用体验:</p>
|
||||
<ul>
|
||||
<li><strong>LiquidJS 应当能够渲染语法正确的 Liquid 模板</strong>。例如 <code>forloop.index</code> 应该是 1 开始的下表,<code>nil</code> 应该渲染成空字符串而不是 <code>undefined</code> 等。即使有些功能(例如 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/harttle/liquidjs/issues/236">#236</a>)用 JavaScript 很难实现,但至少 LiquidJS 会尝试实现所有的 Liquid 语义。</li>
|
||||
<li><strong>所有 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/Shopify/liquid">shopify/liquid</a> 里的标签和过滤器 LiquidJS 都要实现</strong>。这之外有些业务逻辑相关的标签/过滤器尤其是 Shopify 平台上的那些,应该维护在 <a href="./plugins.html#插件列表">插件</a> 里。但是这其中有一些很有用的标签(比如 <code>{% layout %}</code>)LiquidJS 也会考虑实现,可以去开个 Issue 讨论一下。</li>
|
||||
</ul>
|
||||
<p>同时,既然现在用 JavaScript 实现了,那 Liquid 应该有更强的功能:</p>
|
||||
<ul>
|
||||
<li><strong>完全支持异步</strong>。所有过滤器和标签都可以实现为异步,只需要返回 <code>Promise</code> 即可。</li>
|
||||
<li><strong>同时支持同步</strong>。对一些非 I/O 密集的场景,同步渲染会更快。只要模板包含的标签和过滤器都支持同步,你就可以调用类似 <code>.renderSync()</code> 这样的 API。所有内置标签和过滤器都同时支持同步和异步。</li>
|
||||
<li><strong><a href="https://liquidjs.com/tutorials/render-file.html#Abstract-File-System">抽象文件系统</a></strong>。和异步功能一起使用,LiquidJS 可以实现渲染数据库里的模板 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/harttle/liquidjs/discussions/414">#414</a>,远程 HTTP 服务器上的模板 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/harttle/liquidjs/discussions/485">#485</a>,等等。</li>
|
||||
<li><strong>额外的标签和过滤器</strong>。比如 <code>layout</code> 和 <code>json</code>。</li>
|
||||
</ul>
|
||||
<h2 id="区别" class="article-heading"><a href="#区别" class="headerlink" title="区别"></a>区别<a class="article-anchor" href="#区别" aria-hidden="true"></a></h2><p><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/Shopify/liquid">Shopify/liquid</a> 中的所有标签和过滤器 LiquidJS 都支持,但不包括 Shopify 主题中业务逻辑相关的标签和过滤器(如果你在找这些标签可以参考 <a href="./plugins.html#插件列表">插件列表</a>,也欢迎把你的插件添加到列表中)。尽管原则上我们尽力兼容于 Shopify/liquid,但仍然存在一些区别:</p>
|
||||
<ul>
|
||||
<li>真和假。在 LiquidJS 中 <code>undefined</code>, <code>null</code>, <code>false</code> 是假,之外的都是真;在 Ruby 中 <code>nil</code> 和 <code>false</code> 是假,其他都是真。见 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/harttle/liquidjs/pull/26">#26</a>。</li>
|
||||
<li>数字。JavaScript 不区分浮点数和整数,因此缺失一部分整数算术,见 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/harttle/liquidjs/issues/59">#59</a>。此外 <code>size</code> 过滤器作用于数字时总是返回零,而不是 Ruby 中的浮点数或整数的内存大小。</li>
|
||||
@@ -108,7 +121,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="changelog.html" class="article-footer-prev" title="更新日志"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="contribution-guidelines.html" class="article-footer-next" title="贡献指南"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -117,7 +130,7 @@
|
||||
<div id="article-toc-inner">
|
||||
<div id="article-toc-inner-list">
|
||||
<strong class="sidebar-title">目录</strong>
|
||||
|
||||
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%BC%E5%AE%B9%E6%80%A7"><span class="toc-text">兼容性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8C%BA%E5%88%AB"><span class="toc-text">区别</span></a></li></ol>
|
||||
</div>
|
||||
<a href="#" id="article-toc-top">回到顶部</a>
|
||||
</div>
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="setup.html" class="article-footer-next" title="安装"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="truthy-and-falsy.html" class="article-footer-prev" title="真和假"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="changelog.html" class="article-footer-next" title="更新日志"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="plugins.html" class="article-footer-prev" title="插件"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="truthy-and-falsy.html" class="article-footer-next" title="真和假"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="setup.html" class="article-footer-prev" title="安装"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="render-file.html" class="article-footer-next" title="文件渲染"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -163,7 +163,7 @@ engine<span class="token punctuation">.</span><span class="token function">regis
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="access-scope-in-filters.html" class="article-footer-prev" title="过滤器里访问上下文"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="render-tag-content.html" class="article-footer-next" title="渲染标签内容"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -133,7 +133,7 @@ Footer<span aria-hidden="true" class="line-numbers-rows"><span></span><span></sp
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="render-file.html" class="article-footer-prev" title="文件渲染"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="use-in-expressjs.html" class="article-footer-next" title="Express.js 中使用"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -122,7 +122,7 @@ engine<span class="token punctuation">.</span><span class="token function">parse
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="whitespace-control.html" class="article-footer-prev" title="换行和缩进"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="operators.html" class="article-footer-next" title="运算符"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -136,7 +136,7 @@ engine<span class="token punctuation">.</span><span class="token function">regis
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="caching.html" class="article-footer-prev" title="缓存"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="access-scope-in-filters.html" class="article-footer-next" title="过滤器里访问上下文"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -167,7 +167,7 @@ engine<span class="token punctuation">.</span><span class="token function">rende
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="options.html" class="article-footer-prev" title="选项"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="partials-and-layouts.html" class="article-footer-next" title="引用/继承"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="parse-parameters.html" class="article-footer-prev" title="参数解析"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="sync-and-async.html" class="article-footer-next" title="同步和异步"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -138,7 +138,7 @@ engine
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="intro-to-liquid.html" class="article-footer-prev" title="Liquid 简介"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="options.html" class="article-footer-next" title="选项"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -158,7 +158,7 @@ engine<span class="token punctuation">.</span><span class="token function">regis
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="render-tag-content.html" class="article-footer-prev" title="渲染标签内容"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="whitespace-control.html" class="article-footer-next" title="换行和缩进"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="operators.html" class="article-footer-prev" title="运算符"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="migrate-to-9.html" class="article-footer-next" title="迁移到 LiquidJS 9"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -136,7 +136,7 @@ res<span class="token punctuation">.</span><span class="token function">render</
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="partials-and-layouts.html" class="article-footer-prev" title="引用/继承"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="caching.html" class="article-footer-next" title="缓存"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -122,7 +122,7 @@ harttle<span aria-hidden="true" class="line-numbers-rows"><span></span><span></s
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2022-02-26T18:10:48.060Z" itemprop="dateModified">上次更新:2022-02-26</time>
|
||||
<time class="article-footer-updated" datetime="2022-03-02T13:22:52.821Z" itemprop="dateModified">上次更新:2022-03-02</time>
|
||||
<a href="sync-and-async.html" class="article-footer-prev" title="同步和异步"><i class="icon-chevron-left"></i><span>上一页</span></a><a href="plugins.html" class="article-footer-next" title="插件"><span>下一页</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user