HTML_Template_Flexy started it's life as a simplification of HTML_Template_Xipe, however in Version 0.2, It became one of the first template engines to use a real Lexer, rather than regex'es, making it possible to do things like ASP.net or Cold Fusion tags. However, it still has a very simple set of goals.
Very Simple API, easy to learn...
Targeted at Object based systems - default behavior is to display object variables
Designed to allow the documentation of available variables using PEAR standards, eg. PHPDoc comments around object variables
Ability to edit the templates in WYSIWYG HTML editors, without breaking the tags
Fast and Easy to do looping (or blocks), both for designing and runtime
If you look around you will see there are other template systems available in PHP, they generally fall into two categories, Replacement Systems, or PHP Code builders.
Replacement systems like HTML_Template_IT, FastTemplate, PhpLib Template tend to be slower at doing block and nested block type templates and involve alot of code to add each variable to the template.
Php Code builders like Flexy, Smarty, SimpleTemplate (now HTML_Template_Xipe) tend better at more complex templates, and can offer a better approach to extendability.
With Version 0.2, and the introduction of a full Lexer, Flexy offers unique HTML integration with it's foreach,if attributes and the ability to replace HTML Forms with standard PHP code.
Flexy template is normally called from within a Controller Class (in the Model,View,Controller paragam). You just send HTML_Template_Flexy, the name of the template, and the object to output. - any variable you want printing out just has to be set in the object being used to ouput.
Example 25-1. Typical usage example for HTML_Template_Flexy
|
Now the example template,
Example 25-2. Example Template for HTML_Template_Flexy
|
And the output
Example 25-3. Output of example for HTML_Template_Flexy
|