Download the PHP package chrissileinus/template-php without Composer
On this page you can find all versions of the php package chrissileinus/template-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chrissileinus/template-php
More information about chrissileinus/template-php
Files in chrissileinus/template-php
Package template-php
Short Description A template engine to generate strings from a template. Also it is possible to colorize parts with ANSI codes with the help of the ansiPHP class.
License MIT
Informations about the package template-php
templatePHP
A template engine to generate strings from a template. It is also prossible to colorize parts with ANSI codes with the help of the ansiPHP class.
Why
On the search of a simple template engine to generate some output on the bash i found nicmart/StringTemplate. But in the need for static callable methods with colorizing features, I decided to write something similar.
Usage
placeholders
Placeholders are delimited by default by {
and }
, but you can specify others by Str::placeholders()
.
replace
If array key is not specified then write the index into the template.
With specified keys are practical on longer templates.
You are also able to access nested arrays.
You are also able to submit several arrays. All arrays get merged by array_replace_recursive
with the given order.
replaceFormat | replaceF
With the usage of sprintf we are able to use the convertion specifications for the placeholders.
Additionally we also able to colorize the result with the ANSI Commands. Helpful for output in terminal applications.
Just a additional &
and a list of color and styling commands. They can also be spezified in the input array.