Skip to content
docsv0.1.0

TemplateRendererInterface

Renders a named template file against a params array into an HTML string. This is the templating adapter seam: an HTML {@see ComponentRendererInterface} composes markup by rendering per-component template files through here rather than concatenating strings itself, so the template engine (Latte, a minimal built-in engine, ...) can be swapped without touching renderer code.

TemplateRendererInterface::setViewPath()

abstract public function setViewPath(string $path): void

Sets the base directory template paths passed to {@see render()} are resolved against. Implementations MUST reject paths outside this directory (e.g. via `..` traversal) when resolving a template.

Parameters

Parameters of setViewPath()
NameTypeDescription
$pathstring

Throws

\InvalidArgumentException If `$path` does not exist or is not a directory.

TemplateRendererInterface::render()

abstract public function render(string $template, array $params = []): string

Renders the named template (resolved relative to the current view path) with the given params and returns the resulting HTML string.

Parameters

Parameters of render()
NameTypeDescription
$templatestring
$paramsarray<string, mixed>Values the template may reference; implementations decide their own escaping/interpolation rules.