-
-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Description
Version: Nette 3.0 Latte v2.5.x-dev
Bug Description
While including block, unset or null parameters are overwriten by existing variables.
Steps To Reproduce
{define someblock $include ,$text}
<span>{$text}</span>
{if $include}{include someblock false,null}{/if}
{if $include}{include someblock false}{/if}
{/define}
{spaceless}{include someblock true,'text'}{/spaceless}Result is
<span>text</span><span>text</span><span>text</span>Expected Behavior
But it should be
<span>text</span><span></span><span></span>Or at worst
<span>text</span><span></span><span>text</span>Possible Solution
Now the generated code looks like:
extract($_args, EXTR_SKIP);
$include = $_args[0] ?? $include ?? null;
$text = $_args[1] ?? $text ?? null;Meybe better would be:
$include = $_args[0] ?? null;
$text = $_args[1] ?? null;
extract($_args, EXTR_SKIP);So the block arguments has always bigger priority
So the solution is in src/Latte/Macros/BlockMacros.php
change
'<?php extract($_args, EXTR_SKIP);' . ($node->data->args ?? '') . ' ?>'to
'<?php ' . ($node->data->args ?? '') . ' extract($_args, EXTR_SKIP); ?>'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels