Skip to content

Commit

Permalink
Merge pull request #190 from kivudesign/app_view_module
Browse files Browse the repository at this point in the history
App view module
  • Loading branch information
bim-g authored Jun 25, 2024
2 parents 0226847 + 104be58 commit 1d44eef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 5 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions router/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
$router->get('/', function () {
(new View)->display('/home');
});

$router->get('/helloworld', function () {
(new View)->renderHTML('<h1>Hello World!</h1>');
});
$router->get('/home', [\Wepesi\Controller\indexController::class,'home']);
//
$router->post('/changelang', [indexController::class, 'changeLang'])
Expand Down
18 changes: 17 additions & 1 deletion src/Core/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ protected function renderLayout(string $view)
}
}

/**
* render html string text
* @param string $html
* @return void
*/
public function renderHTML(string $html) {
print($html);
}
/**
* @param $html
*
Expand Down Expand Up @@ -244,6 +252,14 @@ public function assign(string $variable, $value)
$this->data[$variable] = $value;
}

/**
* List all data assigned before being displayed
* @return array
*/
public function getAssignData(): array
{
return $this->data;
}
/**
* you should provide the extension of your file,
* in another case the file will be missing
Expand Down Expand Up @@ -273,4 +289,4 @@ public function resetConfig(){
$this->layout = '';
$this->folder_name = '';
}
}
}

0 comments on commit 1d44eef

Please sign in to comment.