mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
Deploying to gh-pages from @ harttle/liquidjs@1c6316111d 🚀
This commit is contained in:
@@ -98,6 +98,30 @@
|
||||
<li>Logic operators: <code>not</code>, <code>or</code>, <code>and</code>, <code>contains</code></li>
|
||||
</ul>
|
||||
<p>Thus numerical operators are not supported and you cannot even plus two numbers like this <code>{{a + b}}</code>, instead we need a filter <code>{{ a | plus: b}}</code>. Actually <code>+</code> is a valid variable name in LiquidJS.</p>
|
||||
<h2 id="Logic-Operators" class="article-heading"><a href="#Logic-Operators" class="headerlink" title="Logic Operators"></a>Logic Operators<a class="article-anchor" href="#Logic-Operators" aria-hidden="true"></a></h2><h3 id="not" class="article-heading"><a href="#not" class="headerlink" title="not"></a>not<a class="article-anchor" href="#not" aria-hidden="true"></a></h3><p>Negates a condition. Returns <code>true</code> if the condition is false, and <code>false</code> if the condition is true.</p>
|
||||
<p>Input</p>
|
||||
<pre class="line-numbers language-liquid" data-language="liquid"><code class="language-liquid"><span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">if</span> not user<span class="token punctuation">.</span>active <span class="token delimiter punctuation">%}</span></span>
|
||||
User is inactive
|
||||
<span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">endif</span> <span class="token delimiter punctuation">%}</span></span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
|
||||
|
||||
<h3 id="and" class="article-heading"><a href="#and" class="headerlink" title="and"></a>and<a class="article-anchor" href="#and" aria-hidden="true"></a></h3><p>Returns <code>true</code> if both conditions are true.</p>
|
||||
<p>Input</p>
|
||||
<pre class="line-numbers language-liquid" data-language="liquid"><code class="language-liquid"><span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">if</span> user<span class="token punctuation">.</span>age <span class="token operator">>=</span> <span class="token number">18</span> <span class="token operator">and</span> user<span class="token punctuation">.</span>verified <span class="token delimiter punctuation">%}</span></span>
|
||||
Access granted
|
||||
<span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">endif</span> <span class="token delimiter punctuation">%}</span></span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
|
||||
|
||||
<h3 id="or" class="article-heading"><a href="#or" class="headerlink" title="or"></a>or<a class="article-anchor" href="#or" aria-hidden="true"></a></h3><p>Returns <code>true</code> if at least one condition is true.</p>
|
||||
<p>Input</p>
|
||||
<pre class="line-numbers language-liquid" data-language="liquid"><code class="language-liquid"><span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">if</span> user<span class="token punctuation">.</span>isAdmin <span class="token operator">or</span> user<span class="token punctuation">.</span>isModerator <span class="token delimiter punctuation">%}</span></span>
|
||||
You have elevated privileges
|
||||
<span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">endif</span> <span class="token delimiter punctuation">%}</span></span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
|
||||
|
||||
<h3 id="contains" class="article-heading"><a href="#contains" class="headerlink" title="contains"></a>contains<a class="article-anchor" href="#contains" aria-hidden="true"></a></h3><p>Checks if a string contains a substring, or if an array contains an element.</p>
|
||||
<p>Input</p>
|
||||
<pre class="line-numbers language-liquid" data-language="liquid"><code class="language-liquid"><span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">if</span> <span class="token object">product</span><span class="token punctuation">.</span>title <span class="token operator">contains</span> <span class="token string">"Pack"</span> <span class="token delimiter punctuation">%}</span></span>
|
||||
This is a pack
|
||||
<span class="token liquid language-liquid"><span class="token delimiter punctuation">{%</span> <span class="token keyword">endif</span> <span class="token delimiter punctuation">%}</span></span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
|
||||
|
||||
<h2 id="Precedence" class="article-heading"><a href="#Precedence" class="headerlink" title="Precedence"></a>Precedence<a class="article-anchor" href="#Precedence" aria-hidden="true"></a></h2><ol>
|
||||
<li>Comparison operators, and <code>contains</code>. All comparison operators alongside <code>contains</code> have the same (highest) precedence.</li>
|
||||
<li><code>not</code> operator. It has slightly more precedence than <code>or</code> and <code>and</code>.</li>
|
||||
@@ -107,7 +131,7 @@
|
||||
|
||||
</div>
|
||||
<footer class="article-footer">
|
||||
<time class="article-footer-updated" datetime="2025-11-21T16:27:57.398Z" itemprop="dateModified">Last updated: 2025-11-21</time>
|
||||
<time class="article-footer-updated" datetime="2026-01-10T14:09:23.347Z" itemprop="dateModified">Last updated: 2026-01-10</time>
|
||||
<a href="plugins.html" class="article-footer-prev" title="Plugins"><i class="icon-chevron-left"></i><span>Prev</span></a><a href="truthy-and-falsy.html" class="article-footer-next" title="Truthy and Falsy"><span>Next</span><i class="icon-chevron-right"></i></a>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -116,7 +140,7 @@
|
||||
<div id="article-toc-inner">
|
||||
<div id="article-toc-inner-list">
|
||||
<strong class="sidebar-title">Contents</strong>
|
||||
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Precedence"><span class="toc-text">Precedence</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Associativity"><span class="toc-text">Associativity</span></a></li></ol>
|
||||
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Logic-Operators"><span class="toc-text">Logic Operators</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#not"><span class="toc-text">not</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#and"><span class="toc-text">and</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#or"><span class="toc-text">or</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#contains"><span class="toc-text">contains</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Precedence"><span class="toc-text">Precedence</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Associativity"><span class="toc-text">Associativity</span></a></li></ol>
|
||||
</div>
|
||||
<a href="#" id="article-toc-top">Back to Top</a>
|
||||
</div>
|
||||
@@ -130,7 +154,7 @@
|
||||
<footer id="footer" class="wrapper">
|
||||
<div class="inner">
|
||||
<div id="footer-copyright">
|
||||
© 2025 <a href="https://github.com/harttle/liquidjs/graphs/contributors" rel="external nofollow noreferrer" target="_blank">Harttle</a><br>
|
||||
© 2026 <a href="https://github.com/harttle/liquidjs/graphs/contributors" rel="external nofollow noreferrer" target="_blank">Harttle</a><br>
|
||||
Documentation licensed under <a href="https://creativecommons.org/licenses/by/4.0/" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>.
|
||||
</div>
|
||||
<div id="footer-links">
|
||||
|
||||
Reference in New Issue
Block a user