Phrender
, (*1)
Phrender is a simplistic PHP renderer that provides a no frills rendering
engine., (*2)
PSR-1 and PSR-4 compliant., (*3)
This uses the Output Interop specification., (*4)
Contexts
The following contexts are provided for use:, (*5)
-
Collection Any number of the following
-
Any Matches any template
-
Contains uses
stripos to match the template
-
Match Uses a regex to match the template
-
Only Will match only the specified template
Installation
Phrender can be installed using composer, (*6)
composer require dlundgren/phrender, (*7)
Basic Usage
var ?>
// output = "something"
$output = $engine->render('index', ['var' => 'something']);
// Alternate
// output = ""
$ctxt = new Phrender\Context\Contains('something', ['var' => 'display']);
$output = $engine->render('index', $ctxt);
Different extension
You may use an alternate extension for the templates with the Template Factory constructor second argument., (*8)
$factory = new Phrender\Template\Factory(['/path/to/views'], 'phtml');
$engine = new Phrender\Engine($factory, new Phrender\Context\Collection());
// index.phtml: = $this->var ?>
// output = "something"
$output = $engine->render('index', ['var' => 'something']);