Version: master (f7b0fa8)
Following code emits notice: PHP Notice: Undefined variable: x
<?php
# composer require latte/latte dev-master
require __DIR__ . '/vendor/autoload.php';
$latte = '
{define a}
{var x => "X"}
{include #b}
{/}
{define b}
{$x}
{/}
{include a}
';
$engine = new Latte\Engine;
$engine->setLoader(new Latte\Loaders\StringLoader);
echo $engine->compile($latte);
$engine->render($latte);
To make it work, I have to pass $x explicitly to block. Or, If I change blocks order, it works:
$latte = '
{define b}
{$x}
{/}
{define a}
{var x => "X"}
{include #b}
{/}
{include a}
';
The only difference between compiled template is in method blockA():
# Non working
function blockA($_args)
{
extract($_args);
$x = "X";
$this->renderBlock('b', $this->params, 'html');
}
# Working
function blockA($_args)
{
extract($_args);
$x = "X";
$this->renderBlock('b', get_defined_vars(), 'html');
}
I'm not sure it is bug or by desing.
Version: master (f7b0fa8)
Following code emits notice:
PHP Notice: Undefined variable: xTo make it work, I have to pass
$xexplicitly to block. Or, If I change blocks order, it works:The only difference between compiled template is in method
blockA():I'm not sure it is bug or by desing.