PHP code example of piotrpress / templater

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

    

piotrpress / templater example snippets




use PiotrPress\Templater;
use PiotrPress\Templater\Template;

$templater = new Templater( __DIR__ . '/templates' );

// Example #1
$templater->display( 'template', [
    'var1' => 'value1',
    'var2' => 'value2'
] );

// Example #2
echo $templater->render( 'template', [
    'var1' => 'value1',
    'var2' => 'value2'
] );

// Example #3
echo new Template( __DIR__ . '/templates/template.php', [
    'var1' => 'value1',
    'var2' => 'value2'
] );