This package allows to use the Fluid template engine in a Tempest application.
First install this Fluid view renderer package (it also installs the required Fluid engine provided by the typo3fluid/fluid package):
composer require jdifool/tempest-fluid-viewThe next step is to provide the configuration needed for Fluid to find your view files.
<?php
// app/fluid.config.php
declare(strict_types=1);
use Jdifool\Tempest\View\Renderers\FluidConfig;
return new FluidConfig(
templateRootPaths: [
__DIR__ . '/../views/Templates/',
],
partialRootPaths: [
__DIR__ . '/../views/Partials/',
],
layoutRootPaths: [
__DIR__ . '/../views/Layouts/',
]
);Finally, update the view configuration to use the Fluid view renderer:
<?php
// app/view.config.php
declare(strict_types=1);
use Tempest\View\ViewConfig;
use Jdifool\Tempest\View\Renderers\FluidViewRenderer;
return new ViewConfig(
rendererClass: FluidViewRenderer::class
);In your controller you can now use Fluid templates like so:
<?php
// app/HomeController.php
namespace App;
use Tempest\Router\Get;
use Tempest\View\View;
use function Tempest\view;
final readonly class HomeController
{
#[Get('/')]
public function __invoke(): View
{
$data = ['foo' => 'bar'];
// __DIR__ . '/../views/Templates/Home/Index.html'
return view('Home/Index', ...$data);
}
}