diff --git a/_basics/types.md b/_basics/types.md index dd57044..84bdc34 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -3,13 +3,14 @@ title: Types description: An overview of data types in the Liquid template language. --- -Liquid objects can have one of five types: +Liquid objects can be one of six types: - [String](#string) - [Number](#number) - [Boolean](#boolean) - [Nil](#nil) - [Array](#array) +- [EmptyDrop](#emptydrop) You can initialize Liquid variables with the [assign]({{ "/tags/variable/#assign" | prepend: site.baseurl }}) or [capture]({{ "/tags/variable/#capture" | prepend: site.baseurl }}) tags. @@ -124,3 +125,31 @@ Adam You cannot initialize arrays using only Liquid. You can, however, use the [split]({{ "/filters/split/" | prepend: site.baseurl }}) filter to break a string into an array of substrings. + +## EmptyDrop + +An EmptyDrop object is returned if you try to access a deleted object. In the example below, `page_1`, `page_2` and `page_3` are all EmptyDrop objects: + +```liquid +{% raw %} +{% assign variable = "hello" %} +{% assign page_1 = pages[variable] %} +{% assign page_2 = pages["does-not-exist"] %} +{% assign page_3 = pages.this-handle-does-not-exist %} +{% endraw %} +``` + +### Checking for emptiness + +You can check to see if an object exists or not before you access any of its attributes. + +```liquid +{% raw %} +{% unless pages == empty %} +