mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
commit
dd6986b60f
@ -7,5 +7,6 @@ require_once __DIR__.'/../tests/tools.php';
|
||||
|
||||
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled');
|
||||
$fenom->setOptions(Fenom::AUTO_RELOAD);
|
||||
$fenom->display(["blocks/body.tpl", "layout.tpl"], []);
|
||||
var_dump($fenom->compile("blocks/second.tpl", false)->getBody());
|
||||
//$fenom->display("blocks/second.tpl", []);
|
||||
// $fenom->getTemplate("problem.tpl");
|
6
sandbox/templates/blocks/main.tpl
Normal file
6
sandbox/templates/blocks/main.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
{* main.tpl *}
|
||||
{extends 'blocks/root.tpl'}
|
||||
{block 'header'}
|
||||
{parent}
|
||||
main header
|
||||
{/block}
|
4
sandbox/templates/blocks/root.tpl
Normal file
4
sandbox/templates/blocks/root.tpl
Normal file
@ -0,0 +1,4 @@
|
||||
{* root.tpl *}
|
||||
{block 'header'}
|
||||
root header
|
||||
{/block}
|
6
sandbox/templates/blocks/second.tpl
Normal file
6
sandbox/templates/blocks/second.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
{* second.tpl *}
|
||||
{extends 'blocks/main.tpl'}
|
||||
{block 'header'}
|
||||
{parent}
|
||||
second header
|
||||
{/block}
|
@ -589,12 +589,10 @@ class Compiler
|
||||
{
|
||||
$tpl = $scope->tpl;
|
||||
$name = $scope["name"];
|
||||
|
||||
if (isset($tpl->blocks[$name])) { // block defined
|
||||
$block = & $tpl->blocks[$name];
|
||||
if ($block['use_parent']) {
|
||||
$parent = $scope->getContent();
|
||||
|
||||
$block['block'] = str_replace($block['use_parent'] . " ?>", "?>" . $parent, $block['block']);
|
||||
}
|
||||
if (!$block["import"]) { // not from {use} - redefine block
|
||||
@ -625,7 +623,7 @@ class Compiler
|
||||
{
|
||||
$block_scope = $scope->tpl->getParentScope('block');
|
||||
if (!$block_scope['use_parent']) {
|
||||
$block_scope['use_parent'] = "/* %%parent#" . mt_rand(0, 1e6) . "%% */";
|
||||
$block_scope['use_parent'] = "/* %%parent#{$scope['name']}%% */";
|
||||
}
|
||||
return $block_scope['use_parent'];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user