mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix bug: invalid cache name then templates extends via array
This commit is contained in:
parent
2fbb6b44e4
commit
ae592d22c7
@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
/** Fenom template 'greeting.tpl' compiled at 2013-09-02 17:37:18 */
|
|
||||||
return new Fenom\Render($fenom, function ($tpl) {
|
|
||||||
?>
|
|
||||||
|
|
||||||
A1
|
|
||||||
<?php
|
|
||||||
/* greeting.tpl:4: {mc.factorial num=10} */
|
|
||||||
$_tpl4154309674_1 = $tpl->exchangeArray(array("num" => 10));
|
|
||||||
?><?php
|
|
||||||
/* macros.tpl:2: {if $num} */
|
|
||||||
if($tpl["num"]) { ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?> <?php
|
|
||||||
/* macros.tpl:3: {macro.factorial num=$num-1} */
|
|
||||||
$_tpl2531688351_1 = $tpl->exchangeArray(array("num" => $tpl["num"] - 1));
|
|
||||||
$tpl->getMacro("factorial")->__invoke($tpl);
|
|
||||||
$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> <?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:4: {/if} */
|
|
||||||
} ?>
|
|
||||||
<?php
|
|
||||||
$tpl->exchangeArray($_tpl4154309674_1); /* X */ unset($_tpl4154309674_1); ?>
|
|
||||||
A2<?php
|
|
||||||
}, array(
|
|
||||||
'options' => 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) {
|
|
||||||
?><?php
|
|
||||||
/* macros.tpl:2: {if $num} */
|
|
||||||
if($tpl["num"]) { ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?> <?php
|
|
||||||
/* macros.tpl:3: {macro.factorial num=$num-1} */
|
|
||||||
$_tpl2531688351_1 = $tpl->exchangeArray(array("num" => $tpl["num"] - 1));
|
|
||||||
$tpl->getMacro("factorial")->__invoke($tpl);
|
|
||||||
$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> <?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:4: {/if} */
|
|
||||||
} ?>
|
|
||||||
<?php
|
|
||||||
}),
|
|
||||||
|
|
||||||
));
|
|
@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
/** Fenom template 'greeting.tpl' compiled at 2013-09-02 17:37:39 */
|
|
||||||
return new Fenom\Render($fenom, function ($tpl) {
|
|
||||||
?>
|
|
||||||
|
|
||||||
A1
|
|
||||||
<?php
|
|
||||||
/* greeting.tpl:4: {mc.factorial num=10} */
|
|
||||||
$_tpl4154309674_1 = $tpl->exchangeArray(array("num" => 10));
|
|
||||||
?><?php
|
|
||||||
/* macros.tpl:2: {if $num} */
|
|
||||||
if($tpl["num"]) { ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?> <?php
|
|
||||||
/* macros.tpl:3: {macro.factorial num=$num-1} */
|
|
||||||
$_tpl2531688351_1 = $tpl->exchangeArray(array("num" => $tpl["num"] - 1));
|
|
||||||
$tpl->getMacro("factorial")->__invoke($tpl);
|
|
||||||
$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> <?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:4: {/if} */
|
|
||||||
} ?>
|
|
||||||
<?php
|
|
||||||
$tpl->exchangeArray($_tpl4154309674_1); /* X */ unset($_tpl4154309674_1); ?>
|
|
||||||
A2<?php
|
|
||||||
}, array(
|
|
||||||
'options' => 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) {
|
|
||||||
?><?php
|
|
||||||
/* macros.tpl:2: {if $num} */
|
|
||||||
if($tpl["num"]) { ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?> <?php
|
|
||||||
/* macros.tpl:3: {macro.factorial num=$num-1} */
|
|
||||||
$_tpl2531688351_1 = $tpl->exchangeArray(array("num" => $tpl["num"] - 1));
|
|
||||||
$tpl->getMacro("factorial")->__invoke($tpl);
|
|
||||||
$tpl->exchangeArray($_tpl2531688351_1); /* X */ unset($_tpl2531688351_1); ?> <?php
|
|
||||||
/* macros.tpl:3: {$num} */
|
|
||||||
echo $tpl["num"]; ?>
|
|
||||||
<?php
|
|
||||||
/* macros.tpl:4: {/if} */
|
|
||||||
} ?>
|
|
||||||
<?php
|
|
||||||
}),
|
|
||||||
|
|
||||||
));
|
|
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/../src/Fenom.php';
|
require_once __DIR__.'/../src/Fenom.php';
|
||||||
|
require_once __DIR__.'/../tests/tools.php';
|
||||||
|
|
||||||
\Fenom::registerAutoload();
|
\Fenom::registerAutoload();
|
||||||
|
|
||||||
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled');
|
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled');
|
||||||
$fenom->setOptions(Fenom::AUTO_RELOAD | Fenom::AUTO_STRIP);
|
$fenom->setOptions(Fenom::AUTO_RELOAD);
|
||||||
echo($fenom->compile("problem.tpl", false)->getBody());
|
$fenom->display(["blocks/body.tpl", "layout.tpl"], []);
|
||||||
// $fenom->getTemplate("problem.tpl");
|
// $fenom->getTemplate("problem.tpl");
|
4
sandbox/templates/blocks/body.tpl
Normal file
4
sandbox/templates/blocks/body.tpl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{block 'body'}
|
||||||
|
|
||||||
|
do extend
|
||||||
|
{/block}
|
7
sandbox/templates/layout.tpl
Normal file
7
sandbox/templates/layout.tpl
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
{block 'body'}
|
||||||
|
nothing to do there
|
||||||
|
{/block}
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -938,7 +938,6 @@ class Fenom
|
|||||||
return $tpl;
|
return $tpl;
|
||||||
}
|
}
|
||||||
} elseif ($this->_options & self::FORCE_COMPILE) {
|
} elseif ($this->_options & self::FORCE_COMPILE) {
|
||||||
|
|
||||||
return $this->compile($template, $this->_options & self::DISABLE_CACHE & ~self::FORCE_COMPILE, $options);
|
return $this->compile($template, $this->_options & self::DISABLE_CACHE & ~self::FORCE_COMPILE, $options);
|
||||||
} else {
|
} else {
|
||||||
return $this->_storage[$key] = $this->_load($template, $options);
|
return $this->_storage[$key] = $this->_load($template, $options);
|
||||||
@ -1020,13 +1019,13 @@ class Fenom
|
|||||||
$template = $this->getRawTemplate()->load($tpl);
|
$template = $this->getRawTemplate()->load($tpl);
|
||||||
} else {
|
} else {
|
||||||
$template = $this->getRawTemplate()->load($tpl[0], false);
|
$template = $this->getRawTemplate()->load($tpl[0], false);
|
||||||
unset($tpl[0]);
|
for($i = 1; $i < count($tpl); $i++) {
|
||||||
foreach ($tpl as $t) {
|
$template->extend($tpl[ $i ]);
|
||||||
$template->extend($t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($store) {
|
if ($store) {
|
||||||
$cache = $this->_getCacheName($tpl, $options);
|
$cache = $this->_getCacheName($tpl, $options);
|
||||||
|
dumpt($cache, $tpl);
|
||||||
$tpl_tmp = tempnam($this->_compile_dir, $cache);
|
$tpl_tmp = tempnam($this->_compile_dir, $cache);
|
||||||
$tpl_fp = fopen($tpl_tmp, "w");
|
$tpl_fp = fopen($tpl_tmp, "w");
|
||||||
if (!$tpl_fp) {
|
if (!$tpl_fp) {
|
||||||
|
@ -7,35 +7,10 @@ define('FENOM_RESOURCES', __DIR__ . "/resources");
|
|||||||
|
|
||||||
require_once FENOM_RESOURCES . "/actions.php";
|
require_once FENOM_RESOURCES . "/actions.php";
|
||||||
require_once __DIR__ . "/TestCase.php";
|
require_once __DIR__ . "/TestCase.php";
|
||||||
|
require_once __DIR__ . "/tools.php";
|
||||||
|
|
||||||
ini_set('date.timezone', 'Europe/Moscow');
|
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) {
|
if(PHP_VERSION_ID > 50400) {
|
||||||
function php_gte_54() {}
|
function php_gte_54() {}
|
||||||
}
|
}
|
27
tests/tools.php
Normal file
27
tests/tools.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user