PHP code example of rusadrako / templater

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

    

rusadrako / templater example snippets




use RusaDrako\templater\Templater;
$templater=new Templater();
$templater->addRootFolder(__DIR__.'/');
$templater->assign('data_1', 'test text 1');
$templater->assign('data_2', 'test text 2');
$templater->display('template_folder/template_name');

use RusaDrako\templater\Templater;
$templater=new Templater();
$templater->addRootFolder(__DIR__.'/');
$templater->display('template_folder/template_name', ['data_1'=>'test text 1', 'data_2'=>'test text 2']);

use RusaDrako\templater\Templater;
$templater=new Templater();
$templater->addRootFolder(__DIR__.'/');
$templater->assign('data_1', 'test text 1');
$templater->assign('data_2', 'test text 2');
echo $templater->render('template_folder/template_name');

use RusaDrako\templater\Templater;
$templater=new Templater();
$templater->addRootFolder(__DIR__.'/');
echo $templater->render('template_folder/template_name', ['data_1'=>'test text 1', 'data_2'=>'test text 2']);

<hr>
 $this->templater->display('template_folder/template_name_2', ['data_3'=>'test text 3'])