Skip to content

Swift-Liquid 1.1.0

Choose a tag to compare

@ThorFuchs ThorFuchs released this 14 Oct 22:14

Swift-Liquid 1.1 adds typed application filters and read-only template inspection
to the dependency-free Shopify Liquid engine. The 1.0 engine initializer and
render APIs remain available, and default engines retain the existing Shopify
core behavior. Requires Swift tools/compiler 6.4 or later, in Swift language mode 6.

Application filters, scoped to an engine

Register immutable LiquidFilter values when constructing an engine. Callbacks
receive LiquidValue input, positional arguments and an ordered LiquidObject
of named values, and return a value asynchronously. Closures and captures use
checked Sendable conformance; parsed templates retain no callbacks.

import Liquid

let engine = try LiquidEngine(filters: [
    LiquidFilter("greet") { value, _, _ in
        guard case .string(let name) = value else { throw LiquidFilterFailure("Expected a name") }
        return .string("Hello, " + name)
    }
])
let output = try await engine.render(template: "{{ name | greet | escape }}", context: ["name": "Ada"])
// Hello, Ada

Standard names and aliases cannot be replaced. Filters are available to supplied
partials and compose with standard filters. Value conversion/admission shares
invocation budgets, including returned values. Only explicit LiquidFilterFailure
errors are recoverable through renderWithDiagnostics; cancellation, quotas,
invalid values and unexpected host errors retain their operational meaning.
Callbacks remain trusted application code; rendering limits do not bound host I/O
or uncooperative execution time. The CLI does not discover or load plugins.

Inspect syntax without rendering

LiquidEngine.inspect(template:syntaxMode:) and inspect(_:) return an immutable
LiquidTemplateInspection: variable roots, filter names, literal partial names,
and whether dynamic partial references occur. Lists preserve exact UTF-8 spelling
and use deterministic ordering. Inspection does not invoke callbacks, evaluate
expressions or load partials.

liquid analyze page.liquid
liquid analyze page.liquid --syntax-mode strict2 --format json

JSON schema 1 gives tools a documented evolution policy. Variable roots are parsed
syntactic reads, including locals and conditional paths; they are not required
context keys. Each template is inspected independently. Source/depth limits and
cancellation apply to source and reused-template inspection.

Compatibility and qualification

  • One Liquid library, one liquid executable, and an empty root dependency graph.
  • Original 1.0 public consumer and all pinned core fixture bytes, licenses, parser
    modes and checksums retained. No custom tags, automatic loaders or new dialect.
  • The pinned Ruby reference still evaluates 2,032 core checks: 1,502 successful
    renders, 337 parsed grammar cases, 132 expected language errors, 26 recovered
    errors and 35 supported-year boundaries. Host extensions have 15 separate paired
    reference cases; inspection tests do not inflate core conformance accounting.
  • Debug/release tests, three public consumers, 33 CLI checks, AddressSanitizer,
    three ThreadSanitizer concurrency cases, four simulator-SDK library compiles,
    compiled DocC and a clean source-archive rebuild.
  • Matched release benchmarks compare all five original workloads against 1.0.0
    using its unchanged harness on the same host/toolchain, with three ABBA blocks
    and verified outputs. New filter and inspection workloads have separate records.
    Per-run latency summaries and review flags accompany the qualification evidence; this
    release makes no general speedup claim.

The numeric/UTC/date-year/resource contracts remain unchanged. Runtime
qualification covers macOS with Swift 6.4; simulator compilation does not certify
device execution, Linux or WASI. Tested cases are evidence, not a proof of complete
Shopify equivalence.

Downloads and upgrade

Select from: "1.1.0" in SwiftPM and keep the Liquid product.
Existing render call sites need no migration. Opt into filters per engine; use
parsed templates and explicit partial maps for application reuse.

Release assets follow the 1.0 layout:

  • Swift-Liquid-source.tar.gz: tracked source, verified by a clean rebuild.
  • Liquid.doccarchive.tar.gz: compiled API reference and guides.
  • Swift-Liquid-qualification.tar.gz: gate receipts, test/reference logs, matched
    benchmark runs, source inventory and archive evidence.
  • SHA256SUMS: SHA-256 checksums for the three archives.

Verify all downloads together with shasum -a 256 -c SHA256SUMS before extraction.
See the filter contract, inspection and JSON schema,
application reuse, CLI, and performance method.

Qualified commit: 1107ec865b9ae7ed35e1245386ba882db3abd93d. All eight main release gates.