pug-php/pug-symfony

View on GitHub
src/Pug/Symfony/Traits/PugRenderer.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

namespace Pug\Symfony\Traits;

use Pug\PugSymfonyEngine;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Templating\TemplateReferenceInterface;
use Symfony\Contracts\Service\Attribute\Required;

trait PugRenderer
{
    protected PugSymfonyEngine $pug;

    #[Required]
    public function setPug(PugSymfonyEngine $pug): void
    {
        $this->pug = $pug;
    }

    public function render(
        string|TemplateReferenceInterface $view,
        array $parameters = [],
        ?Response $response = null,
    ): Response {
        return $this->pug->renderResponse($view, $parameters, $response);
    }
}