LatteTemplateRenderer
Dependency-free {@see TemplateRendererInterface}: a small self-contained subset of Latte syntax (`{layout}`, `{block}`/`{/block}`, `{include}`, `{foreach}`, `{$var}` with auto-escaping and an explicit `|noescape` opt-out) implemented over `preg_replace_callback()`, not the real Latte engine — enough to render this package's shipped templates without pulling in a Composer dependency on `latte/latte`. Every resolved template path is checked against {@see $viewPath} to prevent path traversal outside the configured view root.
LatteTemplateRenderer::__construct()
public function __construct(?string $viewPath = null):Parameters
| Name | Type | Description |
|---|---|---|
| $viewPath | ?string |
LatteTemplateRenderer::setViewPath()
public function setViewPath(string $path): voidSets the root directory templates are resolved (and traversal-checked) against. Throws `InvalidArgumentException` if `$path` does not exist.
Parameters
| Name | Type | Description |
|---|---|---|
| $path | string |
LatteTemplateRenderer::render()
public function render(string $template, array $params = []): stringRenders `$template` (a path relative to {@see $viewPath}, or a `{layout}`-linked template it references) with `$params` available as `{$key}` / `{$key.nested}` placeholders.
Parameters
| Name | Type | Description |
|---|---|---|
| $template | string | |
| $params | array |