diff --git a/_basics/truthy-and-falsy.md b/_basics/truthy-and-falsy.md
index e4f3bd5..bbacdc7 100644
--- a/_basics/truthy-and-falsy.md
+++ b/_basics/truthy-and-falsy.md
@@ -4,9 +4,9 @@ title: Truthy and Falsy
In programming, we describe “truthy” and “falsy” as anything that returns true or false, respectively, when used inside an if statement.
-## What is truthy?
+## What is truthy?
-All values in Liquid are truthy, with the exception of nil and false.
+All values in Liquid are truthy, with the exception of `nil` and `false`.
In the example below, the text “Tobi” is not a boolean, but it is truthy in a conditional:
@@ -17,7 +17,7 @@ This will always be true.
{% endif %}
{% endraw %}{% endhighlight %}
-[Strings](/themes/liquid-documentation/basics/types/#strings), even when empty, are truthy. The example below will result in empty HTML tags if settings.fp_heading is empty:
+[Strings](/themes/liquid-documentation/basics/types/#strings), even when empty, are truthy. The example below will result in empty HTML tags if `settings.fp_heading` is empty:
Input
{% highlight html %}{% raw %} @@ -32,7 +32,7 @@ This will always be true. {% endraw %}{% endhighlight %} -To avoid this, you can check to see if the string isblank, as follows:
+To avoid this, you can check to see if the string is blank, as follows:
blank, as foll
settings.page is an empty string or set to a hidden or deleted object, you will end up with an EmptyDrop. The result is an undesirable empty <div>:
+An [EmptyDrop](/themes/liquid-documentation/basics/types/#empty-drop) is also truthy. In the example below, if `settings.page` is an empty string or set to a hidden or deleted object, you will end up with an EmptyDrop. The result is an undesirable empty <div>:
Input
{% highlight html %}{% raw %} @@ -62,7 +62,7 @@ An [EmptyDrop](/themes/liquid-documentation/basics/types/#empty-drop) is also tr ## What is falsy? -The only values that are falsy in Liquid are nil and false. +The only values that are falsy in Liquid are `nil` and `false`. [nil](/themes/liquid-documentation/basics/types/#nil) is returned when a Liquid object doesn't have anything to return. For example, if a collection doesn't have a collection image, collection.image will be set to nil. Since that is “falsy”, you can do this: @@ -76,7 +76,7 @@ The value false is returned through many Liquid object properties such ## Summary -The table below summarizes what is truthy or falsy in Liquid. +The table below summarizes what is truthy or falsy in Liquid. | | truthy | falsy | | ------------- |:-------------:|:-------------:| @@ -93,25 +93,3 @@ The table below summarizes what is truthy or falsy in Liquid. | collection with no products | × | | | page | × | | | EmptyDrop | × | | - - - - - - - - - - - - - - - - - - - - - - diff --git a/_basics/types.md b/_basics/types.md index b4e1925..da10c96 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -2,152 +2,129 @@ title: Types --- -Liquid objects can return one of six types: String, Number, Boolean, Nil, Array, or EmptyDrop. Liquid variables can be initialized by using the assign or capture tags. +Liquid objects can return one of six types: +- [string](#string) +- [number](#number) +- boolean +- nil +- array +- EmptyDrop +Liquid variables can be initialized by using the [assign](/tags/#assign) or [capture](/tags/#capture) tags. -### Strings +### String -Strings are declared by wrapping the variable's value in single or double quotes. +Strings are declared by wrapping a variable's value in single or double quotes. -Input
{% highlight html %}{% raw %} -Tracking number: {{ fulfillment.tracking_numbers }} +The current user is {{ user.name }} {% endraw %}{% endhighlight %}Output
-Input
-Output
-Input
-Output
-split filter to break a single string into an array of substrings. See here for examples.
-
-
-
-
-
+It is not possible to initialize an array using only Liquid.
+You can, howver, use the [split](/filters/#split) filter to break a single string into an array of substrings.
## EmptyDrop
-An EmptyDrop object is returned whenever you try to access a non-existent object (for example, a collection, page or blog that was deleted or hidden) by [handle](/themes/liquid-documentation/basics/handle). In the example below, page_1, page_2 and page_3 are all EmptyDrop objects.
+An EmptyDrop object is returned whenever you try to access a non-existent object (for example, a collection, page or blog that was deleted or hidden) by [handle](/basics/#Handles). In the example below, `page_1`, `page_2` and `page_3` are all EmptyDrop objects.
{% highlight html %}{% raw %}
{% assign variable = "hello" %}
@@ -156,13 +133,13 @@ An EmptyDrop object is returned whenever you try to access a non-existent object
{% assign page_3 = pages.this-handle-does-not-belong-to-any-page %}
{% endraw %}{% endhighlight %}
-EmptyDrop objects only have one attribute, empty?, which is always true.
+EmptyDrop objects only have one attribute, empty?, which is always true.
-Collections and pages that _do_ exist do not have an empty? attribute. Their empty? is “falsy”, which means that calling it inside an if statement will return false. When using an unless statement on existing collections and pages, empty? will return true.
+Collections and pages that _do_ exist do not have an empty? attribute. Their empty? is “falsy”, which means that calling it inside an if statement will return false. When using an unless statement on existing collections and pages, empty? will return true.
#### Applications in themes
-Using the empty? attribute, you can check to see if a page exists or not _before_ accessing any of its other attributes.
+Using the empty? attribute, you can check to see if a page exists or not _before_ accessing any of its other attributes.
{% highlight html %}{% raw %}
{% unless pages.frontpage.empty? %}
@@ -172,14 +149,14 @@ Using the empty? attribute, you can check to see if a page exists o
{% endunless %}
{% endraw %}{% endhighlight %}
-It is important to see if a page exists or not first to avoid outputting empty HTML elements to the page, as follows:
+It is important to see if a page exists or not first to avoid outputting empty HTML elements to the page, as follows:
{% highlight html %}{% raw %}
{% endraw %}{% endhighlight %}
-You can perform the same verification with collections as well:
+You can perform the same verification with collections as well:
{% highlight html %}{% raw %}
{% unless collections.frontpage.empty? %}