HosipLan

Untitled

Sep 7th, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. use Nette\Latte;
  2. use Nette\Latte\MacroNode;
  3.  
  4. class UIMacros extends Latte\Macros\MacroSet
  5. {
  6.  
  7.     /**
  8.      * @param Latte\Parser $parser
  9.      */
  10.     public static function install(Latte\Parser $parser)
  11.     {
  12.         $me = new static($parser);
  13.         $me->addMacro('box', callback($me, 'macroBoxBegin'), "?>\n\t</div>\n</div>\n<?php");
  14.     }
  15.  
  16.  
  17.  
  18.     /**
  19.      * @param MacroNode $node
  20.      * @param Latte\PhpWriter $writer
  21.      */
  22.     public function macroBoxBegin(MacroNode $node, $writer)
  23.     {
  24.         $title = $node->tokenizer->fetchWord();
  25.         if (!$title) {
  26.             throw new LatteException(); // dohledej si
  27.         }
  28.         $title = $writer->formatWord($title);
  29.  
  30.         // ...
  31.  
  32.         return $writer->write('?><div><?php');
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment