ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Mail\TemplateEngine\TemplateEngineInterface Interface Reference

Interface for template engine functionality used in Mail and related components. More...

+ Inheritance diagram for ILIAS\Mail\TemplateEngine\TemplateEngineInterface:
+ Collaboration diagram for ILIAS\Mail\TemplateEngine\TemplateEngineInterface:

Public Member Functions

 render (string $template, array|object $context)
 Renders a template string with the given context. More...
 

Detailed Description

Interface for template engine functionality used in Mail and related components.

Abstracts the concrete template engine implementation (e.g., Mustache) to enable dependency inversion and easier testing.

Definition at line 28 of file TemplateEngineInterface.php.

Member Function Documentation

◆ render()

ILIAS\Mail\TemplateEngine\TemplateEngineInterface::render ( string  $template,
array|object  $context 
)

Renders a template string with the given context.

Parameters
string$templateThe template string.
array<string,mixed>|object$context Data for the template. Either an associative array of key-value pairs, or an object whose public properties and methods the engine uses to resolve values. Exact behavior depends on the engine implementation.

Example context object with properties, a method, and a list for repeated blocks: $context = new class () { public string $recipient = 'Jane'; public int $amount = 100; public array $lines = [ ['title' => 'Item A', 'qty' => 2], ['title' => 'Item B', 'qty' => 1], ]; public function net_amount(): float { return $this->amount * 0.9; } };

Implemented in ILIAS\Mail\TemplateEngine\Mustache\MustacheTemplateEngine.


The documentation for this interface was generated from the following file: