-
-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Milestone
Description
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.
Metadata
Metadata
Assignees
Labels
No labels