ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Mail\TemplateEngine\Mustache\MustacheTemplateEngine Class Reference

Mustache implementation of the template engine interface. More...

+ Inheritance diagram for ILIAS\Mail\TemplateEngine\Mustache\MustacheTemplateEngine:
+ Collaboration diagram for ILIAS\Mail\TemplateEngine\Mustache\MustacheTemplateEngine:

Public Member Functions

 __construct (private readonly \Mustache\Engine $engine)
 
 render (string $template, array|object $context)
 Renders a template string with the given context. More...
 
 render (string $template, array|object $context)
 Renders a template string with the given context. More...
 

Detailed Description

Mustache implementation of the template engine interface.

Wraps \Mustache\Engine to decouple Mail component from the concrete library.

Definition at line 29 of file MustacheTemplateEngine.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\TemplateEngine\Mustache\MustacheTemplateEngine::__construct ( private readonly \Mustache\Engine  $engine)

Definition at line 31 of file MustacheTemplateEngine.php.

33 {
34 }

Member Function Documentation

◆ render()

ILIAS\Mail\TemplateEngine\Mustache\MustacheTemplateEngine::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; } };

Implements ILIAS\Mail\TemplateEngine\TemplateEngineInterface.

Definition at line 36 of file MustacheTemplateEngine.php.

36 : string
37 {
38 return $this->engine->render($template, $context);
39 }

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