schnittstabil / curty
Simple curly braces micro templating
Installs: 219
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/schnittstabil/curty
Requires
- php: >=7
- schnittstabil/get: ^3.1
Requires (Dev)
This package is auto-updated.
Last update: 2025-09-26 04:22:24 UTC
README
Simple curly braces micro templating.
Install
composer require schnittstabil/curty
Usage
// 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'
License
MIT © schnittstabil