Skip to content

Commit

Permalink
UIMacros: added /* line */ comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 26, 2021
1 parent 29578d9 commit c15bd94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/Bridges/ApplicationLatte/UIMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
);
}

Expand Down
24 changes: 12 additions & 12 deletions tests/Bridges.Latte/UIMacros.link.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ $compiler->setContentType($compiler::CONTENT_TEXT);
UIMacros::install($compiler);

// {link ...}
Assert::same('<?php echo $this->global->uiControl->link("p") ?>', $compiler->expandMacro('link', 'p', '')->openingCode);
Assert::same('<?php echo ($this->filters->filter)($this->global->uiControl->link("p")) ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p:a") ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link($dest) ?>', $compiler->expandMacro('link', '$dest', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link($p:$a) ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("$p:$a") ?>', $compiler->expandMacro('link', '"$p:$a"', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p:a") ?>', $compiler->expandMacro('link', '"p:a"', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link(\'p:a\') ?>', $compiler->expandMacro('link', "'p:a'", '')->openingCode);

Assert::same('<?php echo $this->global->uiControl->link("p", [\'param\']) ?>', $compiler->expandMacro('link', 'p param', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p", [\'param\' => 123]) ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p", [\'param\' => 123]) ?>', $compiler->expandMacro('link', 'p, param => 123', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p"); ?>', $compiler->expandMacro('link', 'p', '')->openingCode);
Assert::same('<?php echo ($this->filters->filter)($this->global->uiControl->link("p")); ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p:a"); ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link($dest); ?>', $compiler->expandMacro('link', '$dest', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link($p:$a); ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("$p:$a"); ?>', $compiler->expandMacro('link', '"$p:$a"', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p:a"); ?>', $compiler->expandMacro('link', '"p:a"', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link(\'p:a\'); ?>', $compiler->expandMacro('link', "'p:a'", '')->openingCode);

Assert::same('<?php echo $this->global->uiControl->link("p", [\'param\']); ?>', $compiler->expandMacro('link', 'p param', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p", [\'param\' => 123]); ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode);
Assert::same('<?php echo $this->global->uiControl->link("p", [\'param\' => 123]); ?>', $compiler->expandMacro('link', 'p, param => 123', '')->openingCode);

0 comments on commit c15bd94

Please sign in to comment.