How to register global macros with Neon?

Notice: This thread is very old.
MartyIX
Member | 217
+
0
-

A simple implementation of an extended Latte Engine that register my macros can be made like this:

namespace MyProject\Application\Latte;

class Engine extends \Nette\Latte\Engine
{

        public function __construct(\Nette\DI\IContainer $container)
        {
                parent::__construct();
                $macros = ['css', 'js', 'confirm', 'rfcLink'];

                foreach ($macros as $item) {
                                $class = "\MyProject\Application\Latte\Macros\\" . ucfirst($item) . "Macro";
                                $class::install($this->compiler);
                }

                return $this;
        }

}

I would like to register the class above as the default Latte Engine class. I tried to use the syntax below in config.neon:

nette:
         latte:
                  class: \MyProject\Application\Latte\Engine

but it throws the exception: Nette\InvalidStateException: “Found sections ‘latte’ in configuration, but corresponding extensions are missing.”

https://doc.nette.org/cs/configuring#…

EDIT: I know that I can register macros in a presenter and in a control but the approach above suits my needs better.

Last edited by MartyIX (2012-08-15 10:11)

HosipLan
Moderator | 4668
+
0
-

If it's not here, it can't work :) Someone has to send a pull request.

HosipLan
Moderator | 4668
+
0
-

I've created a pull request

Last edited by HosipLan (2012-08-15 15:00)

MartyIX
Member | 217
+
0
-

Oh, that's much better than my solution. Thanks! I hope it will be merged.