-
Notifications
You must be signed in to change notification settings - Fork 15
Liquid.NET for Developers
Although the Liquid.NET templating language is very close to Shopify Liquid, the Liquid.NET C# code is very different from the Shopify Ruby implementation.
This page is incomplete—check the Quick Start Guide for some examples in the meantime
Types in liquid are numeric, boolean, string, collection, hash, date, and the special type range. These are represented with C# classes that implement ILiquidValue. There is also the value "nil", which has no liquid type.
| liquid | C# |
|---|---|
| boolean | LiquidBoolean |
| numeric | LiquidNumeric |
| date | LiquidDate |
| string | LiquidString |
| collection | LiquidCollection |
| hash | LiquidHash |
| range* | LiquidRange |
Ranges are currently only available in a few places---most of the rest of this discussion doesn't apply to them. More on this later.
LiquidHashes and LiquidCollections are heterogeneous, meaning that a collection can hold a mix of types, and although the keys of a hash are always strings, a value in a hash can also be of any type.
A numeric has an underlying C# type, which is int, long, decimal or BigInteger. You can create a LiquidNumeric with the static constructor LiquidNumeric.Create(val). This means that if you create a numeric value with the decimal "3.00", it will render as "3.00". If you do math with two numeric values, it will attempt to use the precision of the most precise value, so an "int" LiquidNumeric times a "decimal" LiquidNumeric will yield a decimal LiquidNumeric.
See How to Write a Filter for more details.
See How to Write a Tag or Block for more details.