Closed thekid closed 2 years ago
The extensions argument had to be an array of web.frontend-helpers.Extension instances.
web.frontend-helpers.Extension
new Handlebars($this->environment->path('src/main/handlebars'), [ new Dates(TimeZone::getByName('Europe/Berlin')), new class() extends Extension { public function helpers() { yield 'service' => function($in, $context, $options) { return $context->lookup('request')->uri()->base(); }; } } ]);
We can now substantially shorten the above example:
new Handlebars($this->environment->path('src/main/handlebars'), [ new Dates(TimeZone::getByName('Europe/Berlin')), ['service' => fn($in, $context, $options) => $context->lookup('request')->uri()->base()] ]);
Released in https://github.com/xp-forge/handlebars-templates/releases/tag/v1.2.0
Current code
The extensions argument had to be an array of
web.frontend-helpers.Extension
instances.New code
We can now substantially shorten the above example: