MemoryTemplateEngine
in package
implements
ITemplateEngine
In-memory template engine for testing
Table of Contents
Interfaces
- ITemplateEngine
- Template engine for loading and rendering stub files
Properties
- $templates : array<string|int, mixed>
Methods
- addTemplate() : self
- Add a template to memory
- exists() : bool
- Check if a template exists
- load() : string|null
- Load raw template content
- render() : string
- Render template with data replacements
Properties
$templates
private
array<string|int, mixed>
$templates
= []
Methods
addTemplate()
Add a template to memory
public
addTemplate(string $name, string $content) : self
Parameters
- $name : string
-
Template name
- $content : string
-
Template content
Return values
selfexists()
Check if a template exists
public
exists(string $template) : bool
Parameters
- $template : string
-
Template name (e.g., 'controller.resource.stub')
Tags
Return values
boolload()
Load raw template content
public
load(string $template) : string|null
Parameters
- $template : string
-
Template name
Tags
Return values
string|null —Template content or null if not found
render()
Render template with data replacements
public
render(string $template, array<string|int, mixed> $data) : string
Parameters
- $template : string
-
Template name
- $data : array<string|int, mixed>
-
Key-value pairs for {{placeholder}} replacement
Tags
Return values
string —Rendered content