Defining your own macro is really simple in the Nette Framework, you must first create a MacroSet:
$latte = new Nette\Latte\Engine; $set = new Nette\Latte\Macros\MacroSet($latte->compiler);
then create a new macro using args:
$set->addMacro('if', 'if (%node.args):', 'endif');
And the solution for your second question:
Class MyMacroSet extends Nette\Latte\Macros\MacroSet { public static function install(Nette\Latte\Compiler $compiler) { $compiler->addMacro('if', 'if (%node.args):', 'endif'); } }
and in config.neon you can register your macrosset:
nette.latte: setup: - MyMacroSet::install($service->compiler)
pilec
source share