Skip to content

This library is a simple template engine file loader with variable support.

License

Notifications You must be signed in to change notification settings

PiotrPress/templater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Templater

This library is a simple template engine file loader with variable support.

Installation

composer require piotrpress/templater

Usage

require __DIR__ . '/vendor/autoload.php';

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'
] );

Note: All Errors in templates will be converted to Exceptions.

License

GPL3.0