diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 0593e1935..0dd236c74 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -131,11 +131,12 @@ public function macroControl(MacroNode $node, PhpWriter $writer) public function macroLink(MacroNode $node, PhpWriter $writer) { $node->modifiers = preg_replace('#\|safeurl\s*(?=\||$)#Di', '', $node->modifiers); + $line = $node->startLine ? " /* line $node->startLine */" : ''; return $writer->using($node, $this->getCompiler()) ->write( 'echo %escape(%modify(' . ($node->name === 'plink' ? '$this->global->uiPresenter' : '$this->global->uiControl') - . '->link(%node.word, %node.array?)))' + . "->link(%node.word, %node.array?)))$line;" ); } diff --git a/tests/Bridges.Latte/UIMacros.link.phpt b/tests/Bridges.Latte/UIMacros.link.phpt index 3ae06bfec..adf619400 100644 --- a/tests/Bridges.Latte/UIMacros.link.phpt +++ b/tests/Bridges.Latte/UIMacros.link.phpt @@ -18,15 +18,15 @@ $compiler->setContentType($compiler::CONTENT_TEXT); UIMacros::install($compiler); // {link ...} -Assert::same('global->uiControl->link("p") ?>', $compiler->expandMacro('link', 'p', '')->openingCode); -Assert::same('filters->filter)($this->global->uiControl->link("p")) ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode); -Assert::same('global->uiControl->link("p:a") ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode); -Assert::same('global->uiControl->link($dest) ?>', $compiler->expandMacro('link', '$dest', '')->openingCode); -Assert::same('global->uiControl->link($p:$a) ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode); -Assert::same('global->uiControl->link("$p:$a") ?>', $compiler->expandMacro('link', '"$p:$a"', '')->openingCode); -Assert::same('global->uiControl->link("p:a") ?>', $compiler->expandMacro('link', '"p:a"', '')->openingCode); -Assert::same('global->uiControl->link(\'p:a\') ?>', $compiler->expandMacro('link', "'p:a'", '')->openingCode); - -Assert::same('global->uiControl->link("p", [\'param\']) ?>', $compiler->expandMacro('link', 'p param', '')->openingCode); -Assert::same('global->uiControl->link("p", [\'param\' => 123]) ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode); -Assert::same('global->uiControl->link("p", [\'param\' => 123]) ?>', $compiler->expandMacro('link', 'p, param => 123', '')->openingCode); +Assert::same('global->uiControl->link("p"); ?>', $compiler->expandMacro('link', 'p', '')->openingCode); +Assert::same('filters->filter)($this->global->uiControl->link("p")); ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode); +Assert::same('global->uiControl->link("p:a"); ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode); +Assert::same('global->uiControl->link($dest); ?>', $compiler->expandMacro('link', '$dest', '')->openingCode); +Assert::same('global->uiControl->link($p:$a); ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode); +Assert::same('global->uiControl->link("$p:$a"); ?>', $compiler->expandMacro('link', '"$p:$a"', '')->openingCode); +Assert::same('global->uiControl->link("p:a"); ?>', $compiler->expandMacro('link', '"p:a"', '')->openingCode); +Assert::same('global->uiControl->link(\'p:a\'); ?>', $compiler->expandMacro('link', "'p:a'", '')->openingCode); + +Assert::same('global->uiControl->link("p", [\'param\']); ?>', $compiler->expandMacro('link', 'p param', '')->openingCode); +Assert::same('global->uiControl->link("p", [\'param\' => 123]); ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode); +Assert::same('global->uiControl->link("p", [\'param\' => 123]); ?>', $compiler->expandMacro('link', 'p, param => 123', '')->openingCode);