With the upcoming http-middleware PSR which defines the 
RequestHandlerInterface it becomes possible to write framework independent 
modules that include ready-to-use actions (instances of 
RequestHandlerInterface). However this is not possible, until a common 
interface to render a template exists.
Any action that should work in multiple applications has to render the body 
of the response using templates, that are not part of the module itself. 
While example templates may be included in the module, these are generally 
not usable by the application that uses the module.
It therefore doesn't make sense to include a specific template engine as a 
requirement of the module. Since templates are written using engine 
specific syntax it is not feasible to use multiple template engines.
Consequently an application could only use modules that support the engine 
the application wants to use.

In order to make the used template engine interchangeable a simple 
interface could be defined:

interface TemplateRendererInterface
{
    public function render(ResponseInterface $response, string 
$templatePath, array $data = null): ResponseInterface;
}

This would render the defined template with any data provided and write it 
to the body of the response.
Alternatively the following interface could be defined:

interface TemplateRendererInterface
{
    public function render( string $templatePath, array $data = null): 
string;
}

This provides greater flexibilty while the first interface provides easier 
usage in the specified use case (for request handlers).

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/16475a0c-f46b-4478-ac99-5e9003a97d19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to