This is very simple template engine to parse templates.
php 7.2
via composer
composer require laemmi/simple-template-engine
or use repository
git clone https://github.com/Laemmi/simple-template-engine.git
In this package you have to compiler. Once for replacing variable and one for if statements. For the variable compiler you can use modifiers. In default you can use all php functions like strtoupper etc.
$template = TemplateFactory::factory('My name is {if $name}{#name|strtoupper#}{/if} and i am {#age#} years old.');
$template->name = 'Michael';
$template->age = 99;
$template();
// My name is MICHAEL and i am 99 years old.
$callback = new ModifierCallback('custom', function($value) {
return sprintf('Sir %s', $value);
});
$compiler = new CompileVariable();
$compiler->addModifier($callback);
$template = new Template('My name is {#name|custom#}');
$template->addPlugin($compiler);
$template->name = 'Michael';
$template();
// My name is Sir Michael