FluxTE - A logical & lightweight template engine!
FluxTE
FluxTE or Flux Template Engine is a lightweight, logical and best of all open source template engine for PHP.
It uses a very easy to learn syntax and is very scalable.
Example
index.php:
PHP Code:
<?php
// Include FluxTE.
include_once('../FluxTE.php');
// Instanciate.
$template = new FluxTE();
// Set template root to current directory.
$template->SetTemplateRoot(dirname(__FILE__));
// Assign some mock values.
$template->AssignValue('test', true);
$template->AssignValue('out_test', 'BUDDY');
$template->AssignValue('file_test', 'include');
// Display.
$template->Display('template.tpl');
?>
template.tpl:
PHP Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>FluxTE.php Example</title>
</head>
<body>
<h2>Hello World</h2>
<p>
{if($test)}
Test is assigned!
{else}
Test is not assigned!
{/if}
</p>
<p>
Content of out_test is: {($out_test)}
</p>
<p>
This is included: {include($file_test.tpl)}
</p>
<p>
If without else: {if($test)}{($out_test)}{/if}
</p>
</body>
</html>
Download
All source code and examples used in this post is available on github.
Notes
More in-depth documentation will be available later on as I don't have the time to write it up at the moment.
Re: FluxTE - A logical & lightweight template engine!
Nice. I'd put the different classes in their own files. Pretty good tho. And maybe break up some of the methods into classes themselves. Good comments, tho, but it'd be even easier if it were multiple files, and still light-weight- or even more-so because different parts of the framework will only load when needed, rather then all at once even tho some functions aren't used. Then u should also look into auto-loading with PHP.
Re: FluxTE - A logical & lightweight template engine!
I designed it like this for a reason.
Splitting such a simple script into multiple files would just require more overhead upon including the separate things.
Also, this is not a framework.
Sure, I might split the classes/constants into their own files.
But it would not be for performance reasons.
As I said, it's not too heavy having it all in one class and all things in the file is used eventually.
Re: FluxTE - A logical & lightweight template engine!
Looks nice but it looks limited, I used functions before in an old cms. Looked like a good idea but few weeks later i regretted it.