github.com/wmoxam/liquid-crystal
master / published Sep 26, 2025 / repository
Liquid Markup for Crystal
Liquid template engine
A port of the Liquid template engine to Crystal
Usage
require "liquid-crystal"
markup = "{% if user %}
<p>Hello {{ user.name }}!</p>
{% endif %}"
template = Liquid::Template.parse template
result = template.render({"user" => {"name" => "Matz"}})
# <p>Hello Matz</p>
Development Status
It's still a WIP, however much of the code and specs have been converted. Work needs to be done for added stability, adding missing filters, implementing missing tests
Todo
Missing standard filters
- sort
- map
Missing tests
- Template tokenize tests
- All tests that expect an error to not be raised
Support for procs in templates
- I'm not sure if I actually want to support this
API
- Array(T)
An
Arrayis an ordered, integer-indexed collection of objects of type T. - Bool
Bool has only two possible values:
trueandfalse. - Hash(K, V)
A
Hashrepresents a collection of key-value mappings, similar to a dictionary. - Liquid
- Nil
The
Niltype has only one possible value:nil. - Number
The top-level number type.
- Range(B, E)
A
Rangerepresents an interval: a set of values with a beginning and an end. - String
A
Stringrepresents an immutable sequence of UTF-8 characters. - Symbol
A symbol is a constant that is identified by a name without you having to give it a numeric value.
- Time
Timerepresents a date-time instant in incremental time observed in a specific time zone. - Tuple(*T)
A tuple is a fixed-size, immutable, stack-allocated sequence of values of possibly different types.