Skip to content

Commit

Permalink
Create basic macros set - macro ifCurrentIn
Browse files Browse the repository at this point in the history
  • Loading branch information
jsifalda committed Feb 16, 2014
1 parent ab24e5b commit 4986a01
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Flame/Templating/Macros.php
@@ -0,0 +1,28 @@
<?php
/**
* Class Macros
*
* @author Jiří Šifalda <sifalda.jiri@gmail.com>
* @date 16.02.14
*/
namespace Flame\Templating;

use Nette\Latte\Macros\MacroSet;
use Nette\Latte\Compiler;

class Macros extends MacroSet
{

/**
* @param Compiler $compiler
* @return void|static
*/
public static function install(Compiler $compiler)
{
$set = new static($compiler);
$set->addMacro('ifCurrentIn', function($node, $writer)
{
return $writer->write('foreach (%node.array as $l) { if ($_presenter->isLinkCurrent($l)) { $_c = true; break; }} if (isset($_c)): ');
}, 'endif; unset($_c);');
}
}

0 comments on commit 4986a01

Please sign in to comment.