Div PHP Template Engine 5.1.2
Fixes for orphan conditional parts ant standalone templates
release
version 5.1.2fix
orphan conditional partsfix
standalone preprocessed templates
Now this example works!
cmp.tpl
This is a generic template for create visual components. Each component have a face or content, and more child components. Each child can located in the face of their parent. The template self call recursively.
{strip}
?$location {{{$location} $location?
?$face {$face} $face?
?$components
[$components] component =>
{= component.div.standalone: true =}
{%% cmp: component %%}
[/$components]
$components?
?$location {$location}}} $location?
{/strip}
Button.tpl
<button>{$icon}{$caption}</button>
Page.tpl
<h1>Buttons</h1>
(( top ))
<p>Click on the buttons: <p/>
(( bottom ))
<h1>Fruits</h1>
(( fruits ))
index.php
<?php
use divengine\div;
echo new div("cmp", [
"id" => "welcomePage",
"face" => "{% Page2 %}",
"components" => [
[
"face" => "{% Button %}",
"location" => "top",
"caption" => "Click me",
"icon" => '*'
],
[
"face" => "{% Button %}",
"location" => "bottom",
"caption" => "Click me again",
"icon" => '#'
],
[
"face" => "<ul>(( items ))</ul>",
"location" => "fruits",
"components" => array_map(function ($caption) {
return [
"face" => "<li>{$caption}</li>", // or "<li>{\$caption}</li>" :D
"location" => "items"
];
}, ["Banana", "Apple", "Orange"])
]
]
]
);