|
|
Vivvo Template Engine is a light-weight yet powerful template engine written in PHP and completely PREG based. The system is currently v0.9, beta release.
It consists of only one highly-optimized object-oriented class, using basic, widely used tags like {if}, {foreach}, {literal}, {include}, {variable}. Its power comes from full support for objects, method calls, arrays and recursive templates.
Example usage: Basic template (index.tpl) using recursive inclusion of list.tpl template.
Index.tpl:
--------------------------------------------
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
<head>
<title>{$TITLE}</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
</head>
<body>
<h1>{$TITLE}</h1>
{$list}
<h2>Object test</h2>
<pre>
Object property call: {$object.a}
Object method call: {$object.get_a}
</pre>
<h2>Demo source code:</h2>
<pre>
<code>{$source}</code>
</pre>
</body>
</html>
List.tpl:
--------------------------------------------
<ul>
{foreach item = $item from = $list}
<li>
<span><a href='{$item[href]}'>{$item[title]}</a></span>
{if $item[sub_list] neq ''}
{include file = 'list.tpl' parse list = $item[sub_list]}
{/if}
</li>
{/foreach}
</ul>
It consists of only one highly-optimized object-oriented class, using basic, widely used tags like {if}, {foreach}, {literal}, {include}, {variable}. Its power comes from full support for objects, method calls, arrays and recursive templates.
Example usage: Basic template (index.tpl) using recursive inclusion of list.tpl template.
Index.tpl:
--------------------------------------------
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
<head>
<title>{$TITLE}</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
</head>
<body>
<h1>{$TITLE}</h1>
{$list}
<h2>Object test</h2>
<pre>
Object property call: {$object.a}
Object method call: {$object.get_a}
</pre>
<h2>Demo source code:</h2>
<pre>
<code>{$source}</code>
</pre>
</body>
</html>
List.tpl:
--------------------------------------------
<ul>
{foreach item = $item from = $list}
<li>
<span><a href='{$item[href]}'>{$item[title]}</a></span>
{if $item[sub_list] neq ''}
{include file = 'list.tpl' parse list = $item[sub_list]}
{/if}
</li>
{/foreach}
</ul>
