Where to put the code for user-defined Tags?
- romal
- Member | 16
I want to create my own tag.
I have read https://latte.nette.org/en/develop#…
But I didn't understand in what file to put this code.
index.php? Bootstrap.php? Or some other file?
- romal
- Member | 16
CZechBoY wrote:
Depends on how you use Latte. If you use mvc nette, then you should probably create some latte factory for this setting.
Yes, MVC Nette.
$latte = new Latte\Engine;
$set = new Latte\Macros\MacroSet($latte->getCompiler());
$set->addMacro(‘if’, ‘if (%node.args):’, ‘endif’);
But, in what file to put this 3 lines?
- CZechBoY
- Member | 3608
i hope sth like this
latte.macros:
- MyApp\Templating\MyIfMacroFactory
namespace MyApp\Templating;
class MyIfMacrosFactory
{
public function install(\Latte\Compiler $compiler)
{
$set = new \Latte\Macros\MacroSet($compiler);
$set->addMacro(‘if’, ‘if (%node.args):’, ‘endif’)
return $set;
}