statix/petals
Composer 安装命令:
composer require statix/petals
包简介
A PHP templating engine based on Laravel Blade
关键字:
README 文档
README
Petals is a zero dependency PHP templating engine based on Laravel Blade. This was built as a fun experiment to play with ChatGPT and GitHub Co-pilot, between the two AI tools they wrote ~60% of the code.
Installation
You can install the package via composer:
composer require statix-php/petals
Usage
use Statix\Petals\TemplatingEngine; // require the composer autoloader require __DIR__.'/vendor/autoload.php'; $engine = new TemplatingEngine( templates: __DIR__.'/templates', cachePath: __DIR__.'/cache', ); $engine = new TemplatingEngine( templates: [ __DIR__ . '/templates-one', __DIR__ . '/templates-two', ], cachePath: __DIR__.'/cache', ); // Render the templates/app.blade.php template $content = $engine->render('app', [ 'message' => 'Hello world!', ]); // Render the given string $content = $engine->renderString('Hello {{ $name }}! The unix timestamp is {{ $time }}', [ 'name' => 'world', 'time' => time(), ]); // Compile the template to the cache directory, the compiled template will be used to render the template when render is called $engine->compile('app'); // Compile the given string to the cache directory, if render is called on the same string, it will be rendered from the compiled cache template $engine->compileString('Hello {{ $name }}! The unix timestamp is {{ $time }}'); // Clear the compiled templates $engine->clearCache();
Testing
composer test
Formatting
composer format
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-09
