Repository navigation
v0.13.0-beta.1
Pre-release
Pre-release
Added
- Opt-in compiled template artifacts via
Environment::compile(), loadable withrequire
and supporting both rendering and streaming. TemplatesCache\CompiledTemplatesCachecompiles parsed templates into reusable PHP artifacts on disk.
Breaking changes
Keepsuit\Liquid\Templateis now an interface. UseParsedTemplatefor the concrete
parsed template class;AbstractTemplateis the shared base class. Serialized caches
containing the oldTemplateclass become cache misses.- Replace
new Template($document)withnew ParsedTemplate($document). $template->rootis only available onParsedTemplate; type hints onTemplatekeep working.- Stale serialized entries are reparsed and overwritten on first use; clear the cache on deploy
to avoid the reparse.
- Replace
- Remove the protected
renderOutputmethod fromNodes\Variableand the protected
undefinedandwalkLookupsmethods fromNodes\VariableLookup.- Replace
$this->renderOutput($output)withVariable::renderEvaluated($context, $output). - Subclasses of
VariableLookupshould overrideevaluate()or call
VariableLookup::evaluateParts($context, $name, $lookups), which resolves the lookup chain
and returnsUndefinedVariableunderstrictVariables.
- Replace
- Native nodes and tags now implement
CanBeCompiledorCanBeExported, adding public
compile()andexport()methods.Conditionadds the publiccompileExpression()and
staticcompare()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): voidandexport(CompilerContext $context): ?string.
- Rename unrelated
- Interpreted
BodyNode::stream()now yields chunks of customCanBeStreamednodes 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 render3.0and2.0instead of3and2.
Applyroundor a money filter where an integral output is expected.
plus,minus,times,divided_by,moduloandsumcompute with decimal arithmetic like
Shopify ({{ 0.1 | plus: 0.2 }}renders0.3). Adds thebrick/mathdependency.- Align
tablerowHTML whitespace with Shopify: adjacent cells, newlines between rows,
and a final newline after</tr>. Remove reliance on platform-specific line endings. - Preserve whitespace inside
rawbodies when their delimiters use whitespace control;
the markers continue to trim surrounding text. Environment options remain independent. - Reject incomplete
if/elsif/unlessconditions, empty tags, duplicateforelse
sections, and missing filter arguments withSyntaxExceptionduring 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
CanBeCompilednodes must throwKeepsuit\Liquid\Compiler\UnsupportedNodeException
to request runtime fallback; any other exception aborts compilation. Emit generated
yields throughCompilerContext::writeYield(), notwrite('yield ...'). - Compiled artifact classes are never unloaded in long-running workers.
Performance
- Filesystem template caches keep templates loaded from disk in memory when
keepInMemoryis 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