TEMPLATE PROCESSING

As stated in the paper, one only needs four template constructs: data interpolation, conditional template inclusion based upon presence/absence of an boolean data, recursive template references, and most importantly, template application to a multi-valued data.

In addition to that, Plift also provides a mechanism to remove template elements based upon presence/absence of a boolean data. Any other custom processing must be implemented via a "CUSTOM HANDLER".

DATA INTERPOLATION

Almost any type of data can be made available to the template via "Plift::Context/set". Plift will try to render the best string representation for the each type of data. Templates can reference data via the special HTML attribute data-render="foo" or HTML element <render data="foo">.

Consider the following data:

$tempalte->set(
    name => 'Carlos Fernando',
    now  => DateTime->now,
    is_admin => 1,
    cart => {
        total => 500,
        items => [
            { name => 'Item 01', price => 100, quantity => 1 },
            { name => 'Item 02', price => 200, quantity => 2 },
        ]
    }
);

when consumed by this template:

<div>
    Checkout page for <render data="name">Jhon Doe</render>,
    rendered at <render data="now" format="%F %T">2016-06-30 14:55:43</render>
    <br/>

    Total Price: <b data-render="cart.total">100.0</b>
</div>

<table>
    <tr><td>Name</td><td>Quantity</td><td>Unit Price</td></tr>
    <tr data-render="cart.items">
        <td data-render="name">item 1</td>
        <td data-render="quantity">2</td>
        <td data-render="price" format="currency">R$200</td>
    </tr>
</table>

produces:

<div>
    Checkout page for Carlos Fernando,
    rendered at 2016-06-30 16:49:23
    <br/>

    Total Price: R$500
</div>

<table>
    <tr><td>Name</td><td>Quantity</td><td>Unit Price</td></tr>
    <tr>
        <td>Item 01</td>
        <td>R$100</td>
        <td>1</td>
    </tr>
    <tr>
        <td>Item 02</td>
        <td>R$200</td>
        <td>2</td>
    </tr>
</table>

TEMPLATE INCLUSION

ELEMENT REMOVAL

ATTRIBUTE REFERENCE

CUSTOM HANDLER