elephox / templar
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-09-17 22:39:47 UTC
README
Templar 是一个用于 PHP 的声明式模板引擎。它受到了由 Dart 语言编写的 Flutter 所采用的方法的启发。
基本用法
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()); }