Skip to content

Commit

Permalink
Merge pull request #4 from iiic/patch-1
Browse files Browse the repository at this point in the history
update CommonBasePresenter.php - helpers as macros (pull #4)
  • Loading branch information
zbycz committed Sep 7, 2012
2 parents 56f6d9c + 7111fa3 commit e9fd7d4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/components/CommonBasePresenter.php
Expand Up @@ -68,6 +68,18 @@ protected function createComponent($name){
return parent::createComponent($name);
}

//Allow to use helpers as a latte macros
public function templatePrepareFilters($template) {
$template->registerFilter($e = new Nette\Latte\Engine());
$s = new Nette\Latte\Macros\MacroSet($e->compiler);
$s->addMacro('helper', 'ob_start()',
function($n) {
$w = new \Nette\Latte\PhpWriter($n->tokenizer, $n->args);
return $w->write('echo %modify(ob_get_clean())');
}
);
}

/** Trigger plugin event as filter supplied value
* @param $eventname
* @param $filter value to supply to filter chain
Expand Down

0 comments on commit e9fd7d4

Please sign in to comment.