Skip to content
riaf edited this page Dec 26, 2010 · 1 revision

How to use

php code

<?php
require_once 'LightningTemplate.php';

$items = array(
    'hoge', null, '<b>fuga</b>', 0, 'piyo', '',
);

$lt = new LightningTemplate('sample.html');
$lt->title = 'Sample Template';
$lt->name = 'World';
$lt->message = '<b>hi!</b>';
$lt->items = $items;
echo $lt;

php code (cache on)

<?php
require_once 'LightningTemplate.php';

$items = array(
    'hoge', null, '<b>fuga</b>', 0, 'piyo', '',
);

$lt = new LightningTemplate(
    'sample.html',
    new LightningTemplateCache_File('./cache')
);
$lt->title = 'Sample Template';
$lt->name = 'World';
$lt->message = '<b>hi!</b>';
$lt->items = $items;
echo $lt;

template code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>{{ title }}</title>
</head>
<body>
    <h1>{{ title }}</h1>
    <p>Hello {{ name }}</p>
    <p>{{ message|safe }}</p>
    <h2>Items</h2>
    <ul>
    {% for item in items %}
        {% if item %}
        <li>{{ item }}</li>
        {% endif %}
    {% endfor %}
    </ul>
</body>
</html>