Created
December 12, 2012 12:09
-
-
Save achtan/4267298 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Nette\Latte\Compiler; | |
use Nette\Latte\MacroNode; | |
use Nette\Latte\PhpWriter; | |
class Macros extends \Nette\Latte\Macros\MacroSet { | |
public static function install(Compiler $compiler) { | |
$me = parent::install($compiler); | |
$me->addMacro('timer', array($me, 'macroTimer'), '\Nette\Diagnostics\Debugger::barDump(\Nette\Diagnostics\Debugger::timer(%node.word), %node.word)'); | |
return $me; | |
} | |
public function macroTimer(MacroNode $node, PhpWriter $writer) | |
{ | |
$cmd = '\Nette\Diagnostics\Debugger::timer(%node.word)'; | |
if ($node->isEmpty = (substr($node->args, -1) === '/')) { | |
$cmd = '\Nette\Diagnostics\Debugger::barDump(' . $cmd . ', %node.word)'; | |
return $writer->write($cmd); | |
} else { | |
return $writer->write($cmd); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{timer 'foo' /} | |
{timer 'foo' /} | |
{timer 'bar'}{/timer} | |
<div n:timer="baz"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nechceš z toho zkusit udělat pull request do Nette?