pastebin

Paste Search Dynamic
Recent pastes
BlockMacros defineblock
  1. <?php
  2.  
  3. /**
  4.  * Test: {define ...}
  5.  */
  6.  
  7. use TesterAssert;
  8.  
  9.  
  10. require __DIR__ . '/../bootstrap.php';
  11.  
  12.  
  13. $latte = new LatteEngine;
  14. $latte->setLoader(new LatteLoadersStringLoader);
  15.  
  16. $template = <<<'EOD'
  17.  
  18. {var $var = 10}
  19.  
  20. {define test}
  21.         This is definition #{$var}
  22.  
  23. {include #test, var => 20}
  24.  
  25. {define testargs $var1, $var2}
  26.         Variables {$var1}, {$var2}, {$hello}
  27.  
  28. {include testargs, 1}
  29.  
  30. EOD;
  31.  
  32. assert::matchFile(
  33.         __DIR__ . '/expected/BlockMacros.defineblock.phtml',
  34.         $latte->compile($template)
  35. );
  36. assert::matchFile(
  37.         __DIR__ . '/expected/BlockMacros.defineblock.html',
  38.         $latte->renderToString($template, ['hello' => 'world'])
  39. );
Parsed in 0.052 seconds