pastebin

Paste Search Dynamic
Recent pastes
BlockMacros ifset block
  1. <?php
  2.  
  3. /**
  4.  * Test: LatteMacrosBlockMacros {ifset block}
  5.  */
  6.  
  7. use LatteMacrosBlockMacros;
  8. use TesterAssert;
  9.  
  10.  
  11. require __DIR__ . '/../bootstrap.php';
  12.  
  13.  
  14. $compiler = new LatteCompiler;
  15. BlockMacros::install($compiler);
  16.  
  17. // {ifset ... }
  18. assert::same('<?php if (isset($this->blockQueue["block"])) { ?>', $compiler->expandMacro('ifset', '#block')->openingCode);
  19. assert::same('<?php if (isset($this->blockQueue["block"])) { ?>', $compiler->expandMacro('ifset', 'block')->openingCode);
  20. assert::same('<?php if (isset($this->blockQueue["block"], $item->var["#test"])) { ?>', $compiler->expandMacro('ifset', '#block, $item->var["#test"]')->openingCode);
  21. assert::same(
  22.         '<?php if (isset($this->blockQueue["block1"], $this->blockQueue["block2"], $var3, item('abc'))) { ?>',
  23.         $compiler->expandMacro('ifset', '#block1, block2, $var3, item(abc)')->openingCode
  24. );
  25.  
  26. assert::exception(function () use ($compiler) {
  27.         $compiler->expandMacro('ifset', '$var');
  28. }, 'LatteCompileException', 'Unknown macro {ifset $var}');
  29.  
  30.  
  31. // {elseifset ... }
  32. assert::same('<?php } elseif (isset($this->blockQueue["block"])) { ?>', $compiler->expandMacro('elseifset', '#block')->openingCode);
  33. assert::same('<?php } elseif (isset($this->blockQueue["block"])) { ?>', $compiler->expandMacro('elseifset', 'block')->openingCode);
  34. assert::same('<?php } elseif (isset($this->blockQueue["block"], $item->var["#test"])) { ?>', $compiler->expandMacro('elseifset', '#block, $item->var["#test"]')->openingCode);
  35. assert::same(
  36.         '<?php } elseif (isset($this->blockQueue["block1"], $this->blockQueue["block2"], $var3, item('abc'))) { ?>',
  37.         $compiler->expandMacro('elseifset', '#block1, block2, $var3, item(abc)')->openingCode
  38. );
Parsed in 0.083 seconds