PHP code example of kolserdav / templater

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

    

kolserdav / templater example snippets


use Avir\Templater\Module\Config;

$config = new Config();
$config->setConfig([
    'cache' => '/path/cache/catalog/+{pages}' //default : false  {pages} - auto create catalog
    'userCache' => '/path/usrCache/catalog/+{users}' //default : false {users} - auto create catalog
]);

use Avir\Templater\Module\Render;

$obj = new Render('/path/template/catalog', '/template.file'); 
$obj->render(
    [
        'first_variabe' => 'string', //{{ key }} 
        'second_variable' => 111,
        'for_array1' => [1,2,3,4], //arrays need have 'for_' before
        'for_array2' => [4,3,2,1]
    ],
    [
        'field1' => 'patch.file', //patches repository /template-catalog/views
        'field2' => 'path/patch.file' //patches repository /template-catalog/views/path
        ]);