pastebin

Paste Search Dynamic
Recent pastes
dynamic blocks
  1. <?php
  2.  
  3. /**
  4.  * Test: {block $name} dynamic blocks.
  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. {var $var = 10}
  18.  
  19. {block static}
  20.         static block #{$var}
  21. {/block}
  22.  
  23.  
  24. {foreach [dynamic, static] as $name}
  25.         {block $name}
  26.                 Dynamic block #{$var}
  27.         {/block}
  28. {/foreach}
  29.  
  30. {include dynamic var => 20}
  31.  
  32. {include static var => 30}
  33.  
  34. {include #$name . '', var => 40}
  35.  
  36. {block word$name}<div n:if="false"></div>{/block}
  37.  
  38. {block "strip$name"|striptags}<span>hello</span>{/block}
  39.  
  40. EOD;
  41.  
  42. assert::matchFile(
  43.         __DIR__ . '/expected/BlockMacros.dynamicblock.phtml',
  44.         $latte->compile($template)
  45. );
  46. assert::matchFile(
  47.         __DIR__ . '/expected/BlockMacros.dynamicblock.html',
  48.         $latte->renderToString($template)
  49. );
Parsed in 0.047 seconds