|Last Updated||Ratings||Unique User Downloads||Download Rankings|
|2021-01-08 (11 days ago)||Not yet rated by the users||Total: 45 This week: 3||All time: 9,965 This week: 77|
|absint 1.0||Freeware||7||Templates, PHP 7, Traits|
This package provides a trait to render templates from inside any class.
Absint adds a template engine to your objects with just a few PHP lines. The PHP trait can access basic template functions from inside the Class.
Use the trait to have your objects render themselves or as a replacement for __toString. Bind the replacement functions at runtime with a custom function. Cut & paste some extended functions, or use the supplied extra class Absinter to act as a template engine on its own.
The method parse(text, vars) accepts a template text and replacement variables. The method bind(function) allows for a function to be bound on runtime replacement, i.e. htmlspecialchars and such. The method getPublicVars(object) retrieves the public members of the Class and adds them to the known variables.
The method render accepts an external file by name and calls parse. The method display accepts an external PHP file by name, calls render and evaluates securely using eval() the results.
An Absinter class is also available to act as a template class on its own. It uses the Absint Trait and can memorise the replacements variables: method set(key, value). It contains an additional method tie(object) which takes the public members of the object and adds them to the collection of variables.
An absintf() function is also provided that does almost the same as the absint->parse method. It's a substitute for PHP native functions like sprintf() and vsprintf(). For people that love minimal tech or dislike a class.
Three versions of replacement variables are possible: (1) as an argument to the method calls, (2) the public members, and (3) the memorising version by using the method set (class only). Precedence is (1) - (3) - (2). This means that (2) cannot overwrite (3) cannot overwrite (1). Please note that (3) is not existing in the trait; only in the class.
A simple test (1.php) is available to check the behaviour of the PHP function get_object_vars($object).
This package is meant to study or trial. It is free. Be inspired by it. Share your thoughts, ideas, usage(s) on the forum.
|Version Control||Unique User Downloads||Download Rankings|