切割稳定 / curty
简单的花括号微模板
0.2.1
2017-05-29 09:01 UTC
Requires
- php: >=7
- schnittstabil/get: ^3.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-08-26 01:48:04 UTC
README
简单的花括号微模板。
安装
composer require schnittstabil/curty
用法
// Context (variable lookup table) $ctx = [ 'user' => [ 'login' => 'curt', 'phone' => [ 'internal' => 1337, ], ], 'unicorn' => '{user.login}: {user.phone.internal}', 'lazy' => function ($ctx) : string { return date('z').' {unicorn}'; }, ]; /* * Simple rendering */ use Schnittstabil\Curty; echo Curty\render('{user.login}', $ctx); // => 'curt' echo Curty\render('{unicorn}', $ctx); // => '{user.login}: {user.phone.internal}' echo Curty\render('{lazy}', $ctx); // => '42 {unicorn}' /* * Fixed-point rendering */ use function Schnittstabil\curty; echo curty('{user.login}', $ctx); // => 'curt' echo curty('{unicorn}', $ctx); // => 'curt: 1337' echo curty('{lazy}', $ctx); // => '42 curt: 1337'
许可证
MIT © schnittstabil