mirror of
https://github.com/kemko/liquid.git
synced 2026-01-03 16:55:40 +03:00
WIP
This commit is contained in:
@@ -11,7 +11,6 @@ collections:
|
||||
output: true
|
||||
tags:
|
||||
output: true
|
||||
permalink: /tags/:path/
|
||||
exclude:
|
||||
- README.md
|
||||
- CNAME
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
---
|
||||
title: Control Flow
|
||||
---
|
||||
|
||||
Control Flow tags determine which block of code should be executed based on different conditions.
|
||||
|
||||
|
||||
## if
|
||||
|
||||
<p>Executes a block of code only if a certain condition is met.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% if product.title == 'Awesome Shoes' %}
|
||||
These shoes are awesome!
|
||||
{% endif %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
These shoes are awesome!
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
|
||||
## elsif / else
|
||||
|
||||
<p>Adds more conditions within an <code>if</code> or <code>unless</code> block.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
<!-- If customer.name = 'anonymous' -->
|
||||
{% if customer.name == 'kevin' %}
|
||||
Hey Kevin!
|
||||
{% elsif customer.name == 'anonymous' %}
|
||||
Hey Anonymous!
|
||||
{% else %}
|
||||
Hi Stranger!
|
||||
{% endif %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
Hey Anonymous!
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
## case/when
|
||||
|
||||
<p>Creates a switch statement to compare a variable with different values. <code>case</code> initializes the switch statement, and <code>when</code> compares its values.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% assign handle = 'cake' %}
|
||||
{% case handle %}
|
||||
{% when 'cake' %}
|
||||
This is a cake
|
||||
{% when 'cookie' %}
|
||||
This is a cookie
|
||||
{% else %}
|
||||
This is not a cake nor a cookie
|
||||
{% endcase %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
This is a cake
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## unless
|
||||
|
||||
<p>Similar to <code>if</code>, but executes a block of code only if a certain condition is <strong>not</strong> met.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% unless product.title == 'Awesome Shoes' %}
|
||||
These shoes are not awesome.
|
||||
{% endunless %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
These shoes are not awesome.
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
This would be the equivalent of doing the following:
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% if product.title != 'Awesome Shoes' %}
|
||||
These shoes are not awesome.
|
||||
{% endif %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
27
_tags/control-flow/case-when
Normal file
27
_tags/control-flow/case-when
Normal file
@@ -0,0 +1,27 @@
|
||||
## case/when
|
||||
|
||||
<p>Creates a switch statement to compare a variable with different values. <code>case</code> initializes the switch statement, and <code>when</code> compares its values.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% assign handle = 'cake' %}
|
||||
{% case handle %}
|
||||
{% when 'cake' %}
|
||||
This is a cake
|
||||
{% when 'cookie' %}
|
||||
This is a cookie
|
||||
{% else %}
|
||||
This is not a cake nor a cookie
|
||||
{% endcase %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
This is a cake
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
26
_tags/control-flow/elsif-else.md
Normal file
26
_tags/control-flow/elsif-else.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## elsif / else
|
||||
|
||||
<p>Adds more conditions within an <code>if</code> or <code>unless</code> block.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
<!-- If customer.name = 'anonymous' -->
|
||||
{% if customer.name == 'kevin' %}
|
||||
Hey Kevin!
|
||||
{% elsif customer.name == 'anonymous' %}
|
||||
Hey Anonymous!
|
||||
{% else %}
|
||||
Hi Stranger!
|
||||
{% endif %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
Hey Anonymous!
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
21
_tags/control-flow/if.md
Normal file
21
_tags/control-flow/if.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## if
|
||||
|
||||
<p>Executes a block of code only if a certain condition is met.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% if product.title == 'Awesome Shoes' %}
|
||||
These shoes are awesome!
|
||||
{% endif %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
These shoes are awesome!
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
15
_tags/control-flow/index.html
Normal file
15
_tags/control-flow/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
CONTROL FLOW HERE
|
||||
sss
|
||||
|
||||
{% for doc in site.collections["tags"].docs %}
|
||||
<div id="{{ doc.title }}" class="content__item">
|
||||
<h2 class="content__header">{{ doc.title }}</h2>
|
||||
<div class="content">
|
||||
{{ doc.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
31
_tags/control-flow/unless.md
Normal file
31
_tags/control-flow/unless.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## unless
|
||||
|
||||
<p>Similar to <code>if</code>, but executes a block of code only if a certain condition is <strong>not</strong> met.</p>
|
||||
|
||||
<p class="input">Input</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% unless product.title == 'Awesome Shoes' %}
|
||||
These shoes are not awesome.
|
||||
{% endunless %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<p class="output">Output</p>
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
These shoes are not awesome.
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
|
||||
This would be the equivalent of doing the following:
|
||||
|
||||
<div>
|
||||
{% highlight html %}{% raw %}
|
||||
{% if product.title != 'Awesome Shoes' %}
|
||||
These shoes are not awesome.
|
||||
{% endif %}
|
||||
{% endraw %}{% endhighlight %}
|
||||
</div>
|
||||
@@ -2,11 +2,3 @@
|
||||
layout: default
|
||||
---
|
||||
|
||||
{% for doc in site.collections["basics"].docs %}
|
||||
<div id="{{ doc.title }}" class="content__item">
|
||||
<h2 class="content__header">{{ doc.title }}</h2>
|
||||
<div class="content">
|
||||
{{ doc.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -2,5 +2,10 @@
|
||||
layout: default
|
||||
---
|
||||
|
||||
Tags here.
|
||||
sss
|
||||
|
||||
{{ site.collections["tags"] }}
|
||||
|
||||
{% for doc in site.collections["tags"].docs %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user