diff --git a/11-templating.md b/11-templating.md index 7bfe1aa..dc2d765 100644 --- a/11-templating.md +++ b/11-templating.md @@ -50,7 +50,7 @@ namespace Lubian\NoFramework\Template; interface Renderer { /** @param array $data */ - public function render(string $template, array $data = []) : string; + public function render(string $template, array $data = []): string; } ``` @@ -146,91 +146,14 @@ we can then use it in the factory. In your project root folder, create a `templates` folder. In there, create a file `hello.html`. The content of the file should look like this: ``` -

Hello World

-Hello {{ name }} +

Hello {{name}}

+

The time is: {{time}}

``` Now you can go back to your `Hello` action and change the render line to `$html = $this->renderer->render('hello', $data);` Navigate to the hello page in your browser to make sure everything works. -One thing that still bothers me is the fact that we have some configuration paths scattered in our dependencies -file. We could add a simple valueobject to our code that gives us a typesafe access to our configuration -values. - -Lets create a 'Settings' class in our './src' Folder: - -```php -addDefinitions([ - Settings::class => fn () => require __DIR__ '/settings.php', - ResponseInterface::class => create(Response::class), - ServerRequestInterface::class => fn () => ServerRequestFactory::fromGlobals(), - Renderer::class => fn (ME $me) => new Mustache($me), - MLFsl::class => fn (Settings $s) => new MLFsl($s->templateDir, ['extension' => $s->templateExtension]), - ME::class => fn (MLFsl $MLFsl) => new ME(['loader' => $MLFsl]), -]); - -return $builder->build(); -``` - - - -And as always, don't forget to commit your changes. - +Before you move on to the next chapter be sure to run our quality tools and commit your changes. [<< previous](10-invoker.md) | [next >>](12-configuration.md)