Template engines are frequently used in PHP applications to generate Web pages or some kind of other output from template files or strings, as they make it easy to separate login from presentation code. Usually you use a component that processes a template file or a string and replaces some variables with values passed to the template engine. This package provides an alternative approach by using a trait that can be used by any class. The template variables are replaced by the values of class variables or return values of class functions with the same names. This way developers can easily turn templates into classes of their own that they can call to generate their applications output.

Notable PHP package: Mask

Learn More



Get 100,000 emails per month FREE. No gimmicks. No credit card required.

Rofl, a PHP package is considered Notable when it does something different that is worth noting.

If you have also written Notable packages, contribute them to the PHP Classes site to get your work more exposure.

If your notable package is innovative, you may also earn prizes and recognition in the PHP Innovation Award.

Now you can also win a Big elePHPant as one of the possible prizes you can win every month. Check the complete list of prizes here: List of prizes

Package

Mask

Trait to process templates with class functions

Moderator comment

Template engines are frequently used in PHP applications to generate Web pages or some kind of other output from template files or strings, as they make it easy to separate login from presentation code.

Usually you use a component that processes a template file or a string and replaces some variables with values passed to the template engine.

This package provides an alternative approach by using a trait that can be used by any class. The template variables are replaced by the values of class variables or return values of class functions with the same names.

This way developers can easily turn templates into classes of their own that they can call to generate their applications output.

Author

Marco Afonso

Groups

PHP 5, Templates, Traits

Description

This class provides a trait to process templates with class functions.

It can be included on a class to process templates and use the class function call return values or variable values to replace in the template.

The template engine can compile the templates into PHP scripts and cache them to avoid further processing. It also supports:

1. Conditional sections
2. Foreach iteration loop sections
3. Include external templates
Rofl you are getting this message as free service for being a user of the PHP Classes site to which you registered voluntarily using the email address rofldigger@getsend.xyz. If you wish to unsubscribe go to the unsubscribe page.