Add ViewHelper in view for injecting some basic classes in views
This commit is contained in:
@ -13,9 +13,9 @@ use Ardent\Undercurrent\View\ViewInterface;
|
||||
class HelloWorldController
|
||||
{
|
||||
#[Route('/')]
|
||||
public function index(): ResponseInterface
|
||||
public function index(): ViewInterface
|
||||
{
|
||||
return new GenericResponse('Index, <a href="/hello">Hello</a>');
|
||||
return new BaseView('/index.php');
|
||||
}
|
||||
|
||||
#[Route('/error')]
|
||||
@ -30,10 +30,10 @@ class HelloWorldController
|
||||
return new GenericResponse('Hello World!');
|
||||
}
|
||||
|
||||
#[Route('/view')]
|
||||
public function view(): ViewInterface
|
||||
#[Route('/view/{name}')]
|
||||
public function view(string $name): ViewInterface
|
||||
{
|
||||
return new BaseView('/Template/home.php', ['message' => 'Hello World!']);
|
||||
return new BaseView('/home.php', ['name' => $name]);
|
||||
}
|
||||
|
||||
#[Route('/routes/{word}')]
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php /** @var $this \Ardent\Undercurrent\View\BaseView */ ?>
|
||||
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>TOSTI MAN KOMT JE HALEN</title>
|
||||
<title>Base view title</title>
|
||||
</head>
|
||||
<body>
|
||||
<?= $this->data['slot'] ?>
|
||||
Base, slot: <?= $this->data['slot'] ?>
|
||||
</body>
|
||||
</html>
|
@ -1,4 +1,4 @@
|
||||
<?php /** @var $this \Ardent\Undercurrent\View\BaseView */ ?>
|
||||
<?php $this->extends = '/Template/base.php' ?>
|
||||
<?php $this->extends = '/base.php' ?>
|
||||
|
||||
<?= $this->data['message'] ?>
|
||||
Hello <?= $this->data['name'] ?>!
|
||||
|
4
app/Template/index.php
Normal file
4
app/Template/index.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php /** @var $this \Ardent\Undercurrent\View\BaseView */ ?>
|
||||
<?php $this->extends = '/base.php' ?>
|
||||
|
||||
Hello <a href="<?= $this->helper->getRoute(\App\Controller\HelloWorldController::class, 'hello') ?>">index</a>!
|
Reference in New Issue
Block a user