+813-444-3589+44 118 328 3220+49-231-976765-0 | Contact us

Types

 

Base types:


int

An integer value (in the range of -2,147,483,648 to 2,147,483,647). Int constants must not use a comma or dot as thousands separator, just the plain number (e.g. 1924872).

 

string

A character string which can contain a sequence of any characters. String constants (when used in a template) must be enclosed by  ' or " characters (e.g. 'demo'). A string has a method assigned to it called 'size' which tells the length of the string (e.g. title.size ).

 

float

A floating point value (e.g. 3.142). The decimal point is always the dot character and no thousand seperator must be used. A float constant need to specify the decimal point, as otherwise the constant would be interpreted as an int (e.g. use 5.0 instead of 5).

 

bool

This type can only have two values: true or false. Even though this value could be outputted by a value operation, usually this is only used to decide e.g. whether something should be displayed or not.

 

DateTime

This is a specific date and time which can be outputted in various ways. For an exact format specification please have a look at the date filter.

 

 

Collection types:

All collection types have in common that they collect a specific amount of items. The exact number of items contained within can be queried by using a size identifier (e.g. collections.size where collections is a list of objects). Further all collections have a specific order (e.g. they are sorted alphabetically).

 

List

A collection of items, they can either be iterated one by one (by using a loop), or accessed by a numeric index e.g. product[5], starting by 0 up to number of elements-1.

 

Dictionary

Also a collection of items, which can also be iterated by a loop. But it can also be accessed by a string index (usually called 'handle'). Possible handle values can be accessed using other objects (e.g. the collections dictionary can be also accessed using the handle of one collection (e.g. collections[collection.handle] would be the same as just using collection for a given collection). Some items do use fixed handles so it becomes possible to use constructs as collections['related']. When using constant handles, the following usages are equivalent: collections['related'] and collections.related.

 

 

Object types:

An object could not only contain a single value, but a variety of different values, usually all regarding a specific property of something. E.g. product contains information about the current product (only valid on a product subpage). It contains information about its name, description, pricing and so on. Object values can be accessed by using a . (dot) accessor, e.g. product.title will contain the name of a product.

Of course each value within an object can be of any type, including lists, dictionary and other objects. As a real example from the FlickRocket shop, product.subtitles is a list of SubtitleInformation objects. The type of an object is its structure (and has no values) and will be identified by its internal name. This name will not show up in a Liquid template, but it will be used internally within this documentation to describe exactly of which type an object is (and thus which accessors/values) it owns.

The exact structure of the various supported objects are specified in a later chapter.

 

 

Read more 

More about Liquid placeholders

More about variables