piotrpress / templater
This library is a simple template engine file loader with variable support.
v1.2.0
2024-09-15 16:41 UTC
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2024-12-15 17:07:35 UTC
README
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.