Stamp Template Engine is a string based, logic-less template engine. This means 100% separation between PHP, HTML and data. Working with StampTE is like playing with a paper model; cut out parts and glue them together (a Stamp is also an appropriate metaphor, hence the name of the lib!).
This is how you make a pizza price list for an Italian restaurant using StampTE:
Template:
<table>
<thead>
<tr><th>Pizza</th><th>Price</th></tr>
</thead>
<tbody>
<!-- cut:pizza -->
<tr><td>
#name#
</td><td>
#price#
</td></tr>
<!-- /cut:pizza -->
</tbody>
</table>
Let's add some data:
$data = array(
'Margherita' => '7.00',
'Funghi' => '7.50',
'Tonno' => '8.00'
);
The PHP logic:
$priceList = new StampTE($template);
foreach($data as $name=>$price) {
$pizza = $priceList->getPizza();
$pizza->setName($name);
$pizza->setPrice($price);
$priceList->add($pizza);
}
The resulting HTML:
<table>
<thead><tr><th>Pizza</th><th>Price</th></tr></thead>
<tbody>
<tr><td>Magaritha</td><td>7.00</td></tr>
<tr><td>Funghi</td><td>7.50</td></tr>
<tr><td>Tonno</td><td>8.00</td></tr>
</tbody>
</table>
Output:
| Pizza | Price |
|---|---|
| Margherita | 7.00 |
| Funghi | 7.50 |
| Tonno | 8.00 |
It's Clean. No more PHP in your HTML. This means: toll free template upgrades. Templates no longer have to be converted to be used with PHP logic. Because templates do not have to be adjusted you can show the live templates to your customer in the browser. Templates become plug-and-play. This also makes it a lot easier to exchange templates.
Most template engineers already use HTML markers to mark regions. Stamp Template Engine uses these very same familiar markers for PHP logic. Templates become self-documenting and more readable.
Automatically escapes strings for unicode (X)HTML documents. No more HTML injections! Unit tested. Cleans comment markers afterwards.
Stamp Template Engine for PHP © 2013 Gabor de Mooij and the StampTE community - Licensed New BSD/GPLv2