/ZephyrTemplateEngine

A simple template engine for your php projects.

Primary LanguagePHP

ZephyrTemplateEngine

2019-04-09 -> 2021-03-05

A simple template engine for your php projects.

This is part of the universe framework.

Install

Using the planet installer via light-cli

lt install Ling.ZephyrTemplateEngine

Using the uni command.

uni import Ling/ZephyrTemplateEngine

Or just download it and place it where you want otherwise.

Summary

About

ZephyrTemplateEngine is a template engine which implements the UniversalTemplateEngine interface.

This template engine uses the most flexible template language ever: php.

The template files are regular php files.

Inside template files, the following variables are available:

  • $z: an array containing all the variables passed to the template

Note: this is a simpler version of the ZeusTemplateEngine.

How to use?

  • First create a template file. I will use /path/to/my_app/pages/zephyr/home.php. Put the following content in it.
<h1>The home page</h1>
<p>
    Hello, this is an example template for Zephyr.
    In a Zephyr template, we write the variables using the most flexible template language ever: php.
    For instance, the following fruit is actually a variable, look how it's done in the source code:
</p>
<ul>
    <li>fruit: <?php echo $z['fruit']; ?></li>
</ul>

Now to render the template, do this:

$dir = "/path/to/my_app";
$tpl = "pages/zephyr/home.php";


$o = new ZephyrTemplateEngine();
$o->setDirectory( $dir );
echo $o->renderByPath($tpl, [
    "fruit" => "apple",
]);

History Log

  • 1.1.6 -- 2021-05-31

    • Removing trailing plus in lpi-deps file (to work with Light_PlanetInstaller:2.0.0 api
  • 1.1.5 -- 2021-03-05

    • update README.md, add install alternative
  • 1.1.4 -- 2020-12-08

    • Fix lpi-deps not using natsort.
  • 1.1.3 -- 2020-12-04

    • Add lpi-deps.byml file
  • 1.1.2 -- 2019-07-18

    • update docTools documentation, add links to source code for classes and methods
  • 1.1.0 -- 2019-04-24

    • add ZephyrTemplateEngine->renderFile method
  • 1.0.0 -- 2019-04-09

    • initial commit