youcanshop / liquid
Liquid template engine for themes.
v2.8.0
2026-10-11 21:55 UTC
Requires
- php: ^8.0
Requires (Dev)
- ergebnis/composer-normalize: >=2.8
- friendsofphp/php-cs-fixer: ^3.94
- php-coveralls/php-coveralls: ^2.2
- phpunit/phpunit: ^9.2.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v2.8.0
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- 1.4.45
- 1.4.44
- 1.4.43
- 1.4.42
- 1.4.41
- 1.4.40
- 1.4.39
- 1.4.38
- 1.4.37
- 1.4.36
- 1.4.35
- 1.4.34
- 1.4.33
- 1.4.32
- 1.4.31
- 1.4.30
- 1.4.29
- 1.4.28
- 1.4.27
- 1.4.26
- 1.4.25
- 1.4.24
- 1.4.23
- 1.4.22
- 1.4.21
- 1.4.20
- 1.4.19
- 1.4.18
- 1.4.17
- 1.4.16
- 1.4.15
- 1.4.14
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- dev-float-precision
- dev-output-types
- dev-drop-identity
- dev-no-php-output
- dev-find-reject
- dev-drop-context-first
- dev-uniq-nil
- dev-slimming
This package is auto-updated.
Last update: 2026-10-12 15:29:48 UTC
README
The Liquid engine we use to render themes on YouCan. If you're building a theme, you probably want the theme docs instead.
Install
composer require youcanshop/liquid
Needs PHP 8.0+.
Usage
use YouCan\Liquid\Template; $template = new Template(); $template->parse('Hello, {{ customer.name }}!'); echo $template->render(['customer' => ['name' => 'Ada']]);
Custom tags and filters:
$template->registerTag('section', SectionTag::class); $template->registerFilter('money', fn($amount) => number_format($amount, 2));
Drops
Drops are objects whose fields only load when a template reads them:
use YouCan\Liquid\Drop; class ProductDrop extends Drop { public function __construct(private Product $product) {} public function name(): string { return $this->product->name; } public function reviews(): array { return Review::forProduct($this->product->id); } }
For dynamic keys (e.g. a lookup by handle) override hasKey() and invokeDrop().
Differences from standard Liquid
firstandlastwork mid-path:collection.products.first.name- quoted, numeric and variable keys:
collections['all'],products[0],all_products[handle] map,sortandwhereread drop fields- drops are always truthy, and compare by value when they implement
JsonSerializable
Development
composer test
vendor/bin/php-cs-fixer fix --dry-run --diff
To release, run ./release.sh -p (or -m, -M), then create the GitHub release for the new tag with gh release create <tag> --generate-notes.
Credits
Originally based on kalimatas/php-liquid.
License
MIT