diff --git a/sandbox/fenom.php b/sandbox/fenom.php index 1cfe009..2ac9aef 100644 --- a/sandbox/fenom.php +++ b/sandbox/fenom.php @@ -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"); \ No newline at end of file diff --git a/sandbox/templates/blocks/main.tpl b/sandbox/templates/blocks/main.tpl new file mode 100644 index 0000000..2c27ff8 --- /dev/null +++ b/sandbox/templates/blocks/main.tpl @@ -0,0 +1,6 @@ +{* main.tpl *} +{extends 'blocks/root.tpl'} +{block 'header'} + {parent} + main header +{/block} \ No newline at end of file diff --git a/sandbox/templates/blocks/root.tpl b/sandbox/templates/blocks/root.tpl new file mode 100644 index 0000000..ccc5e8d --- /dev/null +++ b/sandbox/templates/blocks/root.tpl @@ -0,0 +1,4 @@ +{* root.tpl *} +{block 'header'} + root header +{/block} \ No newline at end of file diff --git a/sandbox/templates/blocks/second.tpl b/sandbox/templates/blocks/second.tpl new file mode 100644 index 0000000..2da07f5 --- /dev/null +++ b/sandbox/templates/blocks/second.tpl @@ -0,0 +1,6 @@ +{* second.tpl *} +{extends 'blocks/main.tpl'} +{block 'header'} + {parent} + second header +{/block} \ No newline at end of file diff --git a/src/Fenom/Compiler.php b/src/Fenom/Compiler.php index 08b2c08..5b0f2e3 100644 --- a/src/Fenom/Compiler.php +++ b/src/Fenom/Compiler.php @@ -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']; }