https://github.com/piotrpress/templater
This library is a simple template engine file loader with variable support.
https://github.com/piotrpress/templater
display php php-template-engine render template template-engine templater templates
Last synced: 21 days ago
JSON representation
This library is a simple template engine file loader with variable support.
- Host: GitHub
- URL: https://github.com/piotrpress/templater
- Owner: PiotrPress
- License: gpl-3.0
- Created: 2021-03-23T17:33:10.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-15T16:41:47.000Z (over 1 year ago)
- Last Synced: 2025-08-23T11:29:09.223Z (7 months ago)
- Topics: display, php, php-template-engine, render, template, template-engine, templater, templates
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# Templater
This library is a simple template engine file loader with variable support.
## Installation
```console
composer require piotrpress/templater
```
## Usage
```php
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](license.txt)