Stamp Template Engine

The Stamp Template Engine is a string based, logic-less template engine. This means 100% separation between PHP and HTML.
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!).

Changelog

2.3.1: Added u modifier for better UTF-8 support in regular expression.
2.3.0: UTF-8 support, PHP 7 compatibility, improved HTML5 document template.

News

: Added privacy statement
: Released version 2.3.2
: Released version 2.3.1
: Released version 2.3
: Released version 2.2.2
: Migrated to new server.
: StampTE 2.2.1 has been released, performance improvement.
: Updating documentation
: StampTE 2.2 has been released!

Get started!

Let's begin with a practical example. This is how you make a 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:

    $htmlDocument StampTE::createHtml5Utf8Document();
    
$htmlDocument->setTitle('Pizza');

    
$priceList = new StampTE($template);
    foreach(
$data as $name=>$price) {
        
$pizza $priceList->getPizza();
        
$pizza->setName($name);
        
$pizza->setPrice($price);
        
$priceList->add($pizza);
    }

    
$htmlDocument->body->add($priceList);

The resulting HTML:

    <!DOCTYPE html>
    <
html>
    <
head>
    <
meta charset="UTF-8">
    <
title>Pizza</title>
    </
head>
    <
body>
        <
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>
    </
body>
    </
html>

As you can see in the HTML output above the createHtml5Utf8Document() convenience method creates a valid HTML5 document skeleton for you. We then create a price list from the template string. The resulting output looks like this:


PizzaPrice
Margherita7.00
Funghi7.50
Tonno8.00




How it works

It's easy to see how this template engine works by just reading the example. StampTE simply converts the regions marked in the template to objects you can manipulate. It cuts out the regions and you can then reshuffle them in your HTML.

Logic-less

It's Clean. No more PHP in your HTML.

This also means: toll free template upgrades. Templates no longer have to be converted (insert PHP tags etc...) so you can simply swap files to upgrade your design.

Because templates do not have to be converted anymore 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.

Finally, this approach makes it easy for different teams to work together (design team and development team).

No new syntax

Stamp Template Engine does not require you to learn a new syntax. Instead, Stamp uses markers, HTML comments. These markers are used to identify regions in the HTML template. Most template engineers already use such markers for readability, StampTE makes them even more useful!
Templates become self-documenting and more readable.

StampTE Automatically escapes strings for unicode (X)HTML documents. So no longer have to worry about XSS!

Download

Download the latest version of Stamp Template Engine.

Stamp TE is licensed new BSD. Download Stamp TE v 2.3.2

Privacy

  • We respect your privacy
  • We do not log ANY information about you*
  • We do not place ANY cookies, not a single one
  • We do not track you using localStorage
  • We do not track you using in-browser databases
  • We do not track you using 3rd-party cookies
  • We do not track you using images, tracking pixels, flash, (i)frames or Java Applets
  • We do not track you in any way
  • We do not allow our website to establish connections with other sites without your knowledge
  • We are not responsible for any privacy issues on linked websites but we ensure that you can download the main content from this website and therefore there should be no need to visit external websites for that reason
  • If for some reason you believe we have personal information about you, you can contact us at: gabordemooij at gaborsoftware dot nl and file a request to remove that personal data from our systems

* the only exception to this rule is that we may temporarily log your IP-address in our server logs and firewall log to monitor the quality of our servers and protect our servers from attacks.