Skip to content

v0.13.0-beta.1

Pre-release
Pre-release

Choose a tag to compare

@cappuc cappuc released this 05 Oct 14:25
· 41 commits to main since this release
d25cf3c

Added

  • Opt-in compiled template artifacts via Environment::compile(), loadable with require
    and supporting both rendering and streaming.
  • TemplatesCache\CompiledTemplatesCache compiles parsed templates into reusable PHP artifacts on disk.

Breaking changes

  • Keepsuit\Liquid\Template is now an interface. Use ParsedTemplate for the concrete
    parsed template class; AbstractTemplate is the shared base class. Serialized caches
    containing the old Template class become cache misses.
    • Replace new Template($document) with new ParsedTemplate($document).
    • $template->root is only available on ParsedTemplate; type hints on Template keep working.
    • Stale serialized entries are reparsed and overwritten on first use; clear the cache on deploy
      to avoid the reparse.
  • Remove the protected renderOutput method from Nodes\Variable and the protected
    undefined and walkLookups methods from Nodes\VariableLookup.
    • Replace $this->renderOutput($output) with Variable::renderEvaluated($context, $output).
    • Subclasses of VariableLookup should override evaluate() or call
      VariableLookup::evaluateParts($context, $name, $lookups), which resolves the lookup chain
      and returns UndefinedVariable under strictVariables.
  • Native nodes and tags now implement CanBeCompiled or CanBeExported, adding public
    compile() and export() methods. Condition adds the public compileExpression() and
    static compare() methods. Subclasses that already declare these methods with a different
    signature must be updated.
    • Rename unrelated compile()/export() methods, or match the signatures
      compile(CompilerContext $context): void and export(CompilerContext $context): ?string.
  • Interpreted BodyNode::stream() now yields chunks of custom CanBeStreamed nodes without
    buffering, so stream chunk boundaries may change. The concatenated output is unchanged.
    • Code that inspects individual chunks should concatenate them instead.
  • Align float output and string conversions with Shopify Liquid 5.13: integral floats
    retain .0, full float precision is preserved, and scientific notation follows Ruby.
    Prices and output snapshots may change.
    • {{ 3.0 }} and {{ 2 | times: 1.0 }} now render 3.0 and 2.0 instead of 3 and 2.
      Apply round or a money filter where an integral output is expected.
  • plus, minus, times, divided_by, modulo and sum compute with decimal arithmetic like
    Shopify ({{ 0.1 | plus: 0.2 }} renders 0.3). Adds the brick/math dependency.
  • Align tablerow HTML whitespace with Shopify: adjacent cells, newlines between rows,
    and a final newline after </tr>. Remove reliance on platform-specific line endings.
  • Preserve whitespace inside raw bodies when their delimiters use whitespace control;
    the markers continue to trim surrounding text. Environment options remain independent.
  • Reject incomplete if/elsif/unless conditions, empty tags, duplicate for else
    sections, and missing filter arguments with SyntaxException during parsing. Templates
    previously accepted with these syntax errors must be corrected. Parsing remains strict
    independently of render options; existing strict2-aligned syntax restrictions are unchanged.

Notes

  • Custom CanBeCompiled nodes must throw Keepsuit\Liquid\Compiler\UnsupportedNodeException
    to request runtime fallback; any other exception aborts compilation. Emit generated
    yields through CompilerContext::writeYield(), not write('yield ...').
  • Compiled artifact classes are never unloaded in long-running workers.

Performance

  • Filesystem template caches keep templates loaded from disk in memory when keepInMemory is enabled, instead of reading and unserializing them on every lookup.
  • Faster partial rendering and variable resolution: isolated sub-contexts are cloned instead of
    constructed, and compiled templates output string values without runtime calls.

What's Changed

  • fix(render): do not leak stack traces in arithmetic errors by @cappuc in #85
  • Fix Shopify comparison and lookup semantics by @cappuc in #86
  • fix: align loop, range and counter behaviour with Shopify Liquid by @cappuc in #87
  • Fix date filter strftime formatting by @cappuc in #88
  • Fix Liquid numeric filter coercion and arithmetic semantics by @cappuc in #89
  • Fix strict parsing of incomplete Liquid syntax by @cappuc in #90
  • Fix string and HTML filter compatibility with Shopify Liquid by @cappuc in #91
  • Fix Shopify-compatible array filter coercion and semantics by @cappuc in #92
  • Fix float, tablerow and raw output formatting by @cappuc in #93
  • Keep filesystem-cached templates in memory after the first load by @cappuc in #94
  • Add opt-in compiled template artifacts by @cappuc in #72

Full Changelog: v0.12.1...v0.13.0-beta.1