elephox / templar
A declarative templating engine for PHP.
dev-main
2023-07-17 20:02 UTC
Requires (Dev)
- elephox/framework: dev-develop
- pestphp/pest: ^2.8
This package is auto-updated.
Last update: 2024-10-17 22:52:51 UTC
README
Templar is a declarative templating engine for PHP. It was inspired by the approach used by Flutter, written in Dart.
Basic Usage
class Homepage extends BuildWidget { public function build(): Widget { return new FullscreenDocument( head: new Head(), body: new FullscreenBody( child: new Center( new Text('Hello, world!'), ), ), ); } } $templar = new Templar(); if (str_ends_with($_SERVER['REQUEST_URI'], '.css')) { header('Content-Type: text/css'); echo $templar->renderStyle(new Homepage()); } else { header('Content-Type: text/html'); echo $templar->render(new Homepage()); }