def / view
php view package
dev-master
2016-08-28 19:16 UTC
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2024-10-29 03:53:26 UTC
README
Usage:
use def\View\View; $view = new View(function (array $data) { return print_r($data, true); }); print $view->fetch(['username' => 'guest']);
use def\View\Json; $json = new Json; $json->setPrettyPrint(); print $json->fetch(['some' => ['data']]);
Assigning variables:
$view->assign('username', 'guest'); print $view->fetch();
... with filters:
$view->assign('somevariable', 'somestring', 'ucfirst'); // or $view->assign('somevariable', 'somestring', 'ucfirst', function ($string) { return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); }); // or register filter for reusage: $view->filter('escape', function ($string) { return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); }); $view->assign('somevariable', 'somestring', 'ucfirst', $view->filter('escape'));