package

github.com/wmoxam/liquid-crystal

master / published Sep 26, 2025 / repository

Liquid Markup for Crystal

Build Status

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 Array is an ordered, integer-indexed collection of objects of type T.

  • Bool

    Bool has only two possible values: true and false.

  • Hash(K, V)

    A Hash represents a collection of key-value mappings, similar to a dictionary.

  • Liquid
  • Nil

    The Nil type has only one possible value: nil.

  • Number

    The top-level number type.

  • Range(B, E)

    A Range represents an interval: a set of values with a beginning and an end.

  • String

    A String represents 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

    Time represents 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.