Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

VOLT: macro is already defined

Hi all,

i'm using $this->view->render to render some VOLT templates and store the result in a file later. All works fine but i'm getting in trouble with macros now because VOLT causes an exception if i call multiple times render on the template which contains the macro definition. Off course i can move the declaration in a separate template file but i'm looking for a way to avoid this.

I've even tried with a new view instance with


but even in this case Phalcon complains about double declaration. Can i render a template independently from others with macros available just during that render/file and than discarded?

Thanks very much Gianks


Partially resolved with includes/partials. Passing variables acts like a macro/function call and even if i need more than one template files this way i can render just the "parent" template multiple times without any more code in the controller. I guess this approach leads to poor performances if compared to compiled macros, so i cannot consider this a definitive solution.

Suggestions are welcome!