Template Helper
This helper is used to build file templates from string TemplateHelper::fromString()
or from a stub file TemplateHelper::fromFile()
.
Template Helper is "macroable", which allows you to add additional methods to the TemplateHelper class at run time.
Construct from File
/**
* Load template from file
* @param string $filename
* @return Template
* @throws \Exception
*/
TemplateHelper::fromFile(): void
Construct from String
/**
* Load template from string
* @param string $string
* @return Template
*/
TemplateHelper::fromString(): void
Replace
/**
* Does the actual string replacing
* Expected input it keyed array of changes ("name:modifier" => content).
* It supports some content modifiers like: list, array and string.
* @param array $changes: keyed array, which supports modifiers
* @return Template
* @throws \Exception
*/
TemplateHelper::replace(): void
Build to File
/**
* Write template output to file
* @param string $filepath
* @return string
* @throws \Exception
*/
TemplateHelper::toFile(): void
Build to String
/**
* Output template
* @return string
* @throws \Exception
*/
TemplateHelper::toString(): void
List
/**
* Build an list string from an array or Collection
* @param array|Collection $value
* @return string
*/
TemplateHelper::list(): void
Array
/**
* Build an array string from an array or Collection
* @param array|Collection $value
* @return string
*/
TemplateHelper::array(): void
String
/**
* Build an escaped string
* @param string $value
* @return string
*/
TemplateHelper::string(): void
Integer
/**
* Build an integer from value
* @param int|string $value
* @return int
*/
TemplateHelper::integer(): void