diff --git a/sandbox/compiled/greeting.tpl.baf47f57.10.php b/sandbox/compiled/greeting.tpl.baf47f57.10.php deleted file mode 100644 index d4fadb8..0000000 --- a/sandbox/compiled/greeting.tpl.baf47f57.10.php +++ /dev/null @@ -1,61 +0,0 @@ - - -A1 -exchangeArray(array("num" => 10)); -?> - exchangeArray(array("num" => $tpl["num"] - 1)); -$tpl->getMacro("factorial")->__invoke($tpl); -$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> - -exchangeArray($_tpl4154309674_1); /* X */ unset($_tpl4154309674_1); ?> -A2 128, - 'provider' => false, - 'name' => 'greeting.tpl', - 'base_name' => 'greeting.tpl', - 'time' => 1378125225, - 'depends' => array ( - 0 => - array ( - 'macros.tpl' => 1378129033, - 'greeting.tpl' => 1378125225, - ), -), - 'macros' => array( - 'factorial' => function ($tpl) { -?> - exchangeArray(array("num" => $tpl["num"] - 1)); -$tpl->getMacro("factorial")->__invoke($tpl); -$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> - - - -A1 -exchangeArray(array("num" => 10)); -?> - exchangeArray(array("num" => $tpl["num"] - 1)); -$tpl->getMacro("factorial")->__invoke($tpl); -$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> - -exchangeArray($_tpl4154309674_1); /* X */ unset($_tpl4154309674_1); ?> -A2 0, - 'provider' => false, - 'name' => 'greeting.tpl', - 'base_name' => 'greeting.tpl', - 'time' => 1378125225, - 'depends' => array ( - 0 => - array ( - 'macros.tpl' => 1378129033, - 'greeting.tpl' => 1378125225, - ), -), - 'macros' => array( - 'factorial' => function ($tpl) { -?> - exchangeArray(array("num" => $tpl["num"] - 1)); -$tpl->getMacro("factorial")->__invoke($tpl); -$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> - -setOptions(Fenom::AUTO_RELOAD | Fenom::AUTO_STRIP); -echo($fenom->compile("problem.tpl", false)->getBody()); +$fenom->setOptions(Fenom::AUTO_RELOAD); +$fenom->display(["blocks/body.tpl", "layout.tpl"], []); // $fenom->getTemplate("problem.tpl"); \ No newline at end of file diff --git a/sandbox/templates/blocks/body.tpl b/sandbox/templates/blocks/body.tpl new file mode 100644 index 0000000..e276497 --- /dev/null +++ b/sandbox/templates/blocks/body.tpl @@ -0,0 +1,4 @@ +{block 'body'} + + do extend +{/block} \ No newline at end of file diff --git a/sandbox/templates/layout.tpl b/sandbox/templates/layout.tpl new file mode 100644 index 0000000..f44a769 --- /dev/null +++ b/sandbox/templates/layout.tpl @@ -0,0 +1,7 @@ + + +{block 'body'} +nothing to do there +{/block} + + \ No newline at end of file diff --git a/src/Fenom.php b/src/Fenom.php index a8779e4..837466b 100644 --- a/src/Fenom.php +++ b/src/Fenom.php @@ -938,7 +938,6 @@ class Fenom return $tpl; } } elseif ($this->_options & self::FORCE_COMPILE) { - return $this->compile($template, $this->_options & self::DISABLE_CACHE & ~self::FORCE_COMPILE, $options); } else { return $this->_storage[$key] = $this->_load($template, $options); @@ -1020,13 +1019,13 @@ class Fenom $template = $this->getRawTemplate()->load($tpl); } else { $template = $this->getRawTemplate()->load($tpl[0], false); - unset($tpl[0]); - foreach ($tpl as $t) { - $template->extend($t); + for($i = 1; $i < count($tpl); $i++) { + $template->extend($tpl[ $i ]); } } if ($store) { $cache = $this->_getCacheName($tpl, $options); + dumpt($cache, $tpl); $tpl_tmp = tempnam($this->_compile_dir, $cache); $tpl_fp = fopen($tpl_tmp, "w"); if (!$tpl_fp) { diff --git a/tests/autoload.php b/tests/autoload.php index a9c83fb..0259429 100644 --- a/tests/autoload.php +++ b/tests/autoload.php @@ -7,35 +7,10 @@ define('FENOM_RESOURCES', __DIR__ . "/resources"); require_once FENOM_RESOURCES . "/actions.php"; require_once __DIR__ . "/TestCase.php"; +require_once __DIR__ . "/tools.php"; ini_set('date.timezone', 'Europe/Moscow'); -function drop() -{ - call_user_func_array("var_dump", func_get_args()); - $e = new Exception(); - echo "-------\nDump trace: \n" . $e->getTraceAsString() . "\n"; - exit(); -} - -function dump() -{ - foreach (func_get_args() as $arg) { - fwrite(STDERR, "DUMP: " . call_user_func("print_r", $arg, true) . "\n"); - - } -} - -function dumpt() -{ - foreach (func_get_args() as $arg) { - fwrite(STDERR, "DUMP: " . call_user_func("print_r", $arg, true) . "\n"); - - } - $e = new Exception(); - echo "-------\nDump trace: \n" . $e->getTraceAsString() . "\n"; -} - if(PHP_VERSION_ID > 50400) { function php_gte_54() {} } \ No newline at end of file diff --git a/tests/tools.php b/tests/tools.php new file mode 100644 index 0000000..c1c03a1 --- /dev/null +++ b/tests/tools.php @@ -0,0 +1,27 @@ +getTraceAsString() . "\n"; + exit(); +} + +function dump() +{ + foreach (func_get_args() as $arg) { + fwrite(STDERR, "DUMP: " . call_user_func("print_r", $arg, true) . "\n"); + + } +} + +function dumpt() +{ + foreach (func_get_args() as $arg) { + fwrite(STDERR, "DUMP: " . call_user_func("print_r", $arg, true) . "\n"); + + } + $e = new Exception(); + echo "-------\nDump trace: \n" . $e->getTraceAsString() . "\n"; +} \ No newline at end of file