Skip to content

A simple helper class to process variables and alternative strings.

License

Notifications You must be signed in to change notification settings

kovsky0/mini-templater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MiniTemplater class

A simple helper class to process variables and alternative strings. Based on Spintax by Jason Davis.

Installation

Install via Composer

composer require kovsky0/mini-templater

Getting started

To get started you need to require mini-templater.php

<?php
require_once('vendor/autoload.php');

How to use it

Processing alternatives:

<?php
$templater = new MiniTemplater;
$example = "This is an {{example.|exemplary usage of the class.}}";
echo $templater->process($example);

Processing alternatives recursively:

<?php
$templater = new MiniTemplater;
$example = "This is an {{example.|exemplary usage of {{the|my}} class.}}";
echo $templater->process($example);

Processing variables:

<?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:

<?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);

About

A simple helper class to process variables and alternative strings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages