Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 months 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 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-15T16:41:47.000Z (3 months ago)
- Last Synced: 2024-10-29T06:05:54.148Z (about 2 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)