FXL Template
News:
2008-07-07: FXL-Template 2.1 available (incl. "memcached" alpha ext.)
What is FXL Template?
FXL Template an easy to use template engine covering all the basic features of a template
system. It supports simple text/array assignments, blocks and nested blocks. Well-
used regular expressions and the simple markup are responsible for quick rendering.
The template markup is really easy to learn - even for people not into programming. Everything
can be done with just two types of place holders. For high traffic enviroments you are
invited to test our "memcached" cache extension.
hello world example:
Template (example.tpl)
{greeting}
PHP-Code (demo.php)
require_once 'fxl_template.inc.php';
$fxlt = new fxl_template('example.tpl');
$fxlt->assign('greeting', 'hello world!');
$fxlt->display;
Output
hello world!
more complex example:
Template (example.tpl)
<table>
<!-- START row -->
<tr>
<!-- START cell --><td>{td_value}</td><!-- END cell -->
</tr>
<!-- END row -->
</table>
PHP-Code (demo.php)
require_once 'fxl_template.inc.php';
$fxlt = new fxl_template('example.tpl');
$fxlt_row = $fxlt->get_block('row');
$fxlt_cell = $fxlt_row->get_block('cell');
for ($tr = 1; $tr <= 3; $tr++) {
for ($td = 1; $td <= 3; $td++) {
$fxlt_cell->assign('td_value', $tr.':'.$td);
$fxlt_row->assign('cell', $fxlt_cell);
$fxlt_cell->clear();
}
$fxlt->assign('row', $fxlt_row);
$fxlt_row->clear();
}
$fxlt->display();
Output
<table>
<tr>
<td>1:1</td><td>1:2</td><td>1:3</td>
</tr>
<tr>
<td>2:1</td><td>2:2</td><td>2:3</td>
</tr>
<tr>
<td>3:1</td><td>3:2</td><td>3:3</td>
</tr>
</table>