A few years back, there was a trend in the PHP community to make alternative templating languages that ran inside PHP. This was so the designers could create HTML templates, and include bits of code to display data. The best was probably Smarty.
After a while with this, a counter-trend emerged, of rejecting adding yet-another-language to the system. After all, PHP was a templating language. Some web frameworks used PHP as the templating language, but simply asked that only a tiny subset of the syntax be used. CodeIgniter and Savant did this. (So did the never released Slaptech code generator.)
I was firmly in this latter camp. There are already too many languages involved with PHP: PHP, Javascript, HTML, CSS, and xml. Templating systems are slower, too.
The world has changed, though. Today, due to AJAX, you need to produce lists of data encoded into xml, or into fragments of HTML.
You can easily do this with regular PHP... except that PHP can sometimes look sloppy, and leave you wanting a simple templating language. What's below is an extremely limited templating language, implemented in a single function.
Additionally, there are two more functions that will apply the template to arrays and iterators.
If you copy this code to a file, and run it on the server, it'll demo each function. More programming blather after the code.
<?phpSo, clearly, you can use these functions to build pages in a functional-language style. Just define templates and immediately apply them to iterators that wrap around queries. Producing html or xml from queries is simplified. Best of all (for me) you can write more code in a functional style than in the dreaded OO style.
echo str_merge_iterator( 'template{here}', query('select here from foobar where here>100') );
It's not really that terse, but, the idea is, you're not writing any more loops. All that is hidden.