Awesome Solution, found on the Phalcon Forums. Customized just a little to my situation.
Suggestion was to extend the Volt Engine Class and then load each macro file during \Phalcon\Mvc\View\Engine\Volt::getCompiler
.
// extended class to load the macros before parse time
class VoltC extends \Phalcon\Mvc\View\Engine\Volt
{
public function getCompiler()
{
if (empty($this->_compiler))
{
parent::getCompiler();
// add macros that need initialized before parse time
$this->partial("macros/form");
}
return parent::getCompiler();
}
}
$di->set("voltEngine", function( $view, $di ){
$volt = new VoltC($view, $di);
$volt->setOptions(array(
"compiledPath" => "../app/tmp/cache/",
"compiledExtension" => ".cmp",
'compileAlways' => true
));
return $volt;
});