PHP code example of stuartwakefield / templating

1. Go to this page and download the library: Download stuartwakefield/templating 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/ */

    

stuartwakefield / templating example snippets


<p>Hey there, <?= $this->name 


emplating\Template;

$template = new Template('templates/greeting.phtml');
$result = $template->fill(array(
	'name' => 'Bob'
));
echo $result; // <p>Hey there, Bob!</p>


class Presenter {

	private $name;

	function __construct($name) {
		$this->name = $name;
	}
	
	function greet() {
		return 'Hello, ' . $name . '! You are logged in.';
	}
	
}

<p><?= $this->greet() 


emplating\Template;

$template = new Template('templates/account.phtml');
$presenter = new Presenter('Khan');
$result = $template->fill($presenter);
echo $result; // <p>Hello, Khan! You are logged in.</p>