mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
Deploying to gh-pages from @ harttle/liquidjs@822ba0be0f 🚀
This commit is contained in:
@@ -97,9 +97,16 @@
|
||||
<blockquote class="note info"><strong class="note-title">API 文档</strong><p>下面的所有选项的概述,希望了解具体的类型和签名,请前往 <a href="https://liquidjs.com/api/interfaces/liquid_options_.liquidoptions.html" target="_self">LiquidOptions | API</a>.</p>
|
||||
</blockquote>
|
||||
|
||||
<h2 id="cache" class="article-heading"><a href="#cache" class="headerlink" title="cache"></a>cache<a class="article-anchor" href="#cache" aria-hidden="true"></a></h2><p><strong>cache</strong> 用来指定是否缓存曾经读取和处理过的模板来提升性能。在生产环境模板会重复渲染的情况会很有用。</p>
|
||||
<h2 id="缓存" class="article-heading"><a href="#缓存" class="headerlink" title="缓存"></a>缓存<a class="article-anchor" href="#缓存" aria-hidden="true"></a></h2><p><strong>cache</strong> 用来指定是否缓存曾经读取和处理过的模板来提升性能。在生产环境模板会重复渲染的情况会很有用。</p>
|
||||
<p>默认是 <code>false</code>,当设置为 <code>true</code> 时会启用一个大小为 1024 的 LRU 缓存。当然也可以传一个数字来指定缓存大小。此外还可以是一个自定义的缓存实现,LiquidJS 会通过它来查找和读写文件。详情请参考 <a href="./caching.html">Caching</a>。</p>
|
||||
<h2 id="dynamicPartials" class="article-heading"><a href="#dynamicPartials" class="headerlink" title="dynamicPartials"></a>dynamicPartials<a class="article-anchor" href="#dynamicPartials" aria-hidden="true"></a></h2><p><strong>dynamicPartials</strong> 表示是否把传给 <a href="../tags/include.html">include</a>, <a href="../tags/render.html">render</a>, <a href="../tags/layout.html">layout</a> 标签的文件名当做变量处理。默认为 <code>true</code>。例如用上下文 <code>{ file: 'foo.html' }</code> 渲染下面的模板将会引入文件 <code>foo.html</code>:</p>
|
||||
<h2 id="布局和片段" class="article-heading"><a href="#布局和片段" class="headerlink" title="布局和片段"></a>布局和片段<a class="article-anchor" href="#布局和片段" aria-hidden="true"></a></h2><p><strong>root</strong> 用来指定 LiquidJS 查找和读取模板的根目录。可以是单个字符串,也可以是一个数组 LiquidJS 会顺序查找。详情请参考 <a href="./render-file.html">Render Files</a>。</p>
|
||||
<p><strong>layouts</strong> 和 <code>root</code> 具有一样的格式,用来指定 <code>{% layout %}</code> 所使用的目录。没有指定时默认为 <code>root</code>。</p>
|
||||
<p><strong>partials</strong> 和 <code>root</code> 具有一样的格式,用来指定 <code>{% render %}</code> 和 <code>{% include %}</code> 所使用的目录。没有指定时默认为 <code>root</code>。</p>
|
||||
<p><strong>relativeReference</strong> 默认为 <code>true</code> 用来允许以相对路径引用其他文件。注意被引用的文件仍然需要在对应的 root 目录下。例如可以这样引用一个文件 <code>{% render ../foo/bar %}</code>,但需要确保 <code>../foo/bar</code> 处于 <code>partials</code> 目录下。</p>
|
||||
<h2 id="动态引用" class="article-heading"><a href="#动态引用" class="headerlink" title="动态引用"></a>动态引用<a class="article-anchor" href="#动态引用" aria-hidden="true"></a></h2><blockquote>
|
||||
<p>注意由于历史原因这个选项叫做 dynamicPartials,但它对 layout 也起作用。</p>
|
||||
</blockquote>
|
||||
<p><strong>dynamicPartials</strong> 表示是否把传给 <a href="../tags/include.html">include</a>, <a href="../tags/render.html">render</a>, <a href="../tags/layout.html">layout</a> 标签的文件名当做变量处理。默认为 <code>true</code>。例如用上下文 <code>{ file: 'foo.html' }</code> 渲染下面的模板将会引入文件 <code>foo.html</code>:</p>
|
||||
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">{% include file %}</span><br></pre></td></tr></table></figure>
|
||||
|
||||
<p>设置 <code>dynamicPartials: false</code> 后 LiquidJS 将会尝试去读取 <code>file</code>。当你的模板之间都是静态引入关系时会很有用:</p>
|
||||
@@ -114,13 +121,12 @@
|
||||
<blockquote class="note info"><strong class="note-title">旧版行为</strong><p>在 2.0.1 之前,<code>extname</code> 默认值为 <code>.liquid</code>。要禁用它需要明确设置为 <code>extname: ''</code>。详情参考 <a href="https://github.com/harttle/liquidjs/issues/41" rel="external nofollow noreferrer" target="_blank">#41</a>。</p>
|
||||
</blockquote>
|
||||
|
||||
<h2 id="root" class="article-heading"><a href="#root" class="headerlink" title="root"></a>root<a class="article-anchor" href="#root" aria-hidden="true"></a></h2><p><strong>root</strong> 用来指定 LiquidJS 查找和读取模板的根目录。可以是单个字符串,也可以是一个数组 LiquidJS 会顺序查找。详情请参考 <a href="./render-file.html">Render Files</a>。</p>
|
||||
<h2 id="fs" class="article-heading"><a href="#fs" class="headerlink" title="fs"></a>fs<a class="article-anchor" href="#fs" aria-hidden="true"></a></h2><p><strong>fs</strong> 用来自定义文件系统实现,详情请参考 <a href="./render-file.html#Abstract-File-System">Abstract File System</a>。</p>
|
||||
<h2 id="globals" class="article-heading"><a href="#globals" class="headerlink" title="globals"></a>globals<a class="article-anchor" href="#globals" aria-hidden="true"></a></h2><p><strong>globals</strong> 用来定义对所有模板可见的全局变量。包括 <a href="../tags/render.html">render tag</a> 引入的子模板,见 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/harttle/liquidjs/issues/185">3185</a>。</p>
|
||||
<h2 id="jsTruthy" class="article-heading"><a href="#jsTruthy" class="headerlink" title="jsTruthy"></a>jsTruthy<a class="article-anchor" href="#jsTruthy" aria-hidden="true"></a></h2><p><strong>jsTruthy</strong> 用来使用 Javascript 的真值判断,默认为 <code>false</code> 使用 Shopify 方式。</p>
|
||||
<p>例如,空字符串在 JavaScript 中为假(<code>jsTruthy</code> 为 <code>true</code> 时),在 Shopify 真值表中为真。</p>
|
||||
<h2 id="时间日期和时区" class="article-heading"><a href="#时间日期和时区" class="headerlink" title="时间日期和时区"></a>时间日期和时区<a class="article-anchor" href="#时间日期和时区" aria-hidden="true"></a></h2><p><strong>timezoneOffset</strong> 用来指定一个和你当地时区不同的时区,所有日期和时间输出时都转换到这个指定的时区。例如设置 <code>timezoneOffset: 0</code> 将会把所有日期按照 UTC/GMT 00:00 来输出。</p>
|
||||
<p><strong>preserveTimezones</strong> 是一个布尔值,只影响时间戳字面量。当设置为 <code>true</code> 时,所有字面量的时间戳字符串会在输出时保持原状,即不论输入时采取怎样的时区,输出时仍然采用那一时区(和 Shopify Liquid 的行为一致)。注意这是一个解析器参数,渲染时传入的数据中的日期的输出不会受此参数影响。</p>
|
||||
<p><strong>preserveTimezones</strong> 是一个布尔值,只影响时间戳字面量。当设置为 <code>true</code> 时,所有字面量的时间戳字符串会在输出时保持原状,即不论输入时采取怎样的时区,输出时仍然采用那一时区(和 Shopify Liquid 的行为一致)。注意这是一个解析器参数,渲染时传入的数据中的日期的输出不会受此参数影响。注意 <code>preserveTimezones</code> 比 <code>timezoneOffset</code> 的优先级更高。</p>
|
||||
<h2 id="换行和缩进" class="article-heading"><a href="#换行和缩进" class="headerlink" title="换行和缩进"></a>换行和缩进<a class="article-anchor" href="#换行和缩进" aria-hidden="true"></a></h2><p><strong>greedy</strong>, <strong>trimOutputLeft</strong>, <strong>trimOutputRight</strong>, <strong>trimTagLeft</strong>, <strong>trimTagRight</strong> 选项用来移除 Liquid 语法周围的换行和缩进,详情请参考 <a href="./whitespace-control.html">Whitespace Control</a>。</p>
|
||||
<h2 id="自定义分隔符" class="article-heading"><a href="#自定义分隔符" class="headerlink" title="自定义分隔符"></a>自定义分隔符<a class="article-anchor" href="#自定义分隔符" aria-hidden="true"></a></h2><p><strong>outputDelimiterLeft</strong>, <strong>outputDelimiterRight</strong>, <strong>tagDelimiterLeft</strong>, <strong>tagDelimiterRight</strong> 用来自定义 LiquidJS 中 <a href="./intro-to-liquid.html">标签和过滤器</a> 的分隔符。例如设置了 <code>outputDelimiterLeft: <%=, outputDelimiterRight: %></code> 后我们可以避免跟其他模板引擎冲突:</p>
|
||||
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"><%= username | append: ", welcome to LiquidJS!" %></span><br></pre></td></tr></table></figure>
|
||||
@@ -134,7 +140,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2021-10-04T13:36:24.231Z" itemprop="dateModified">上次更新:2021-10-04</time>
|
||||
<time class="article-footer-updated" datetime="2021-10-06T10:43:44.817Z" itemprop="dateModified">上次更新:2021-10-06</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>
|
||||
@@ -143,7 +149,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="#cache"><span class="toc-text">cache</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#dynamicPartials"><span class="toc-text">dynamicPartials</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#extname"><span class="toc-text">extname</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#root"><span class="toc-text">root</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#fs"><span class="toc-text">fs</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#globals"><span class="toc-text">globals</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#jsTruthy"><span class="toc-text">jsTruthy</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%97%B6%E9%97%B4%E6%97%A5%E6%9C%9F%E5%92%8C%E6%97%B6%E5%8C%BA"><span class="toc-text">时间日期和时区</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8D%A2%E8%A1%8C%E5%92%8C%E7%BC%A9%E8%BF%9B"><span class="toc-text">换行和缩进</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%86%E9%9A%94%E7%AC%A6"><span class="toc-text">自定义分隔符</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%A5%E6%A0%BC%E6%A8%A1%E5%BC%8F"><span class="toc-text">严格模式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0%E9%A1%BA%E5%BA%8F"><span class="toc-text">参数顺序</span></a></li></ol>
|
||||
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%93%E5%AD%98"><span class="toc-text">缓存</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%83%E5%B1%80%E5%92%8C%E7%89%87%E6%AE%B5"><span class="toc-text">布局和片段</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8A%A8%E6%80%81%E5%BC%95%E7%94%A8"><span class="toc-text">动态引用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#extname"><span class="toc-text">extname</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#fs"><span class="toc-text">fs</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#globals"><span class="toc-text">globals</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#jsTruthy"><span class="toc-text">jsTruthy</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%97%B6%E9%97%B4%E6%97%A5%E6%9C%9F%E5%92%8C%E6%97%B6%E5%8C%BA"><span class="toc-text">时间日期和时区</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8D%A2%E8%A1%8C%E5%92%8C%E7%BC%A9%E8%BF%9B"><span class="toc-text">换行和缩进</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%86%E9%9A%94%E7%AC%A6"><span class="toc-text">自定义分隔符</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%A5%E6%A0%BC%E6%A8%A1%E5%BC%8F"><span class="toc-text">严格模式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0%E9%A1%BA%E5%BA%8F"><span class="toc-text">参数顺序</span></a></li></ol>
|
||||
</div>
|
||||
<a href="#" id="article-toc-top">回到顶部</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user