PHP code example of grithin / phptemplate

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

    

grithin / phptemplate example snippets


$Template = new \Grithin\Template(['directory'=>__DIR__.'/templates/']);
$Template->get('page', ['first_name'=>'bob']);

$Template = new Template([
	'helpers'=>[
		'upper'=>function($x){ return strtoupper($x)},
		'name' => 'bob'	]])

$template->get('view_user', ['t'=> 'this will override the template variable for this template file inclusion'])
html
<?= $Template->get('sidemenu') 
html
<?= $Template->get('./sidemenu') 
html
<?= isset($vars['name']) ? $name : 'Default Person' 

 $Template->parent('layout') 
html
<html><body> <?= $Template->inner 
html
<!-- create a header section and put meta tag into it -->
	$Template->section('header') 
html
	$Template->section('header') 
html
	$Template->sections['title']='The Page Title' 
html
 $Template->parent('layout', ['theme'=>'blue'])