Template

Introduction

We use native PHP for template rendering. All template files are located under the templates directory with .phtml extension.

Render

To output a dynamc HTML page to browser, we need to create a template. Let's create a template file called hello/someone.phtml in templates directory.

<p>Hello, <?=$name?>.</p>

Then create a handler file src/Handlers/Hello.php for passing value to the template.

namespace App\Handlers;

use Rise\{Response, Template};

class Hello {
	public function someone(Response $response, Template $template) {
		$html = $template->render('hello/someone', [
			'name' => 'Rise',
		]);
        $response->asHtml()->send($html);
	}
}

Reuse

Include

Extend