dev-master
9999999-devA simple helper class to process variables and alternative strings
GPL-3.0
by Jason Davis
Wallogit.com
2017 © Pedro Peláez
A simple helper class to process variables and alternative strings
A simple helper class to process variables and alternative strings. Based on Spintax by Jason Davis., (*1)
Install via Composer, (*2)
composer require kovsky0/mini-templater
To get started you need to require mini-templater.php, (*3)
<?php
require_once('vendor/autoload.php');
Processing alternatives:, (*4)
<?php
$templater = new MiniTemplater;
$example = "This is an {{example.|exemplary usage of the class.}}";
echo $templater->process($example);
Processing alternatives recursively:, (*5)
<?php
$templater = new MiniTemplater;
$example = "This is an {{example.|exemplary usage of {{the|my}} class.}}";
echo $templater->process($example);
Processing variables:, (*6)
<?php
$templater = new MiniTemplater;
$example = "This is an [[example_text]]";
$variables = array("example_text" => "exemplary usage of the class.");
echo $templater->process($example, $variables);
Processing alternatives inside variables:, (*7)
<?php
$templater = new MiniTemplater;
$example = "This is an [[example_text]]";
$variables = array("example_text" => "{{example.|exemplary usage of the class.}}");
echo $templater->process($example, $variables);
A simple helper class to process variables and alternative strings
GPL-3.0