How to create new macro in Latte?
Notice: This thread is very old.
- droa22
- Member | 6
I see that macros are defined in file
vendor/nette/nette/Nette/Latte/Macros/UIMacros.php
… but where is
the best place for add new macro in my project and don't change the original
code of nette?.
My idea:
// someTemplate.latte
{addCss '/folder1/folder2/file.css'}
is equivalent to:
// someTemplate.latte
{$presenter->myContainerForCss->addCss('/folder1/folder2/file.css')}
myContainerForCss
is my component for render and min css in my
templates.
- Felix
- Nette Core | 1193
Best way is in config file.
latte:
xhtml: yes # default is no
macros:
- App\MyLatteMacros::register # static method, classname or callable