PHP code example of onnerby / doerender

1. Go to this page and download the library: Download onnerby/doerender library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

onnerby / doerender example snippets


\Doe\Render::$basePath = __DIR__ . '/views/';
$renderer = \Doe\Render::nestedView()
	->add('layout.php', ['title' => 'Default title']);

$renderer->add('embed_view.php', ['viewdata' => 'Stuff']);

echo $renderer->render(); 

<html>
<head>
	<title><?= $title 

<h1><?= $viewdata 

<html>
<head>
	<title>Default title</title>
</head>
<body>
	<h1>Stuff</h1>
</body>
</html>

\Doe\Render::$basePath = __DIR__ . '/views/';
$renderer = \Doe\Render::nestedView()
	->add('layout.php', ['title' => 'Default title']);

// If you can't access the renderer, we have a helper
\Doe\Render::nestedView()->add('embed_view.php', ['viewdata' => 'Stuff']);

// Arguments in higher view can be overwritten by a third argument
\Doe\Render::nestedView()->add('final_view.php', ['finaldata' => 'Other Stuff'], ['title' => 'Special final_view title']);

echo \Doe\Render::nestedView()->render();