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.

Help with macro

I'm following the docs ( ) to create a macro, but I just get a "undefined function" exception.

The macro (templates/admin.volt):

{%- macro admin() %}
    <h3>WORK DAMMIT</h3>
{%- endmacro %}

Then, in the template:

{% include 'templates/admin.volt' %}
{{ admin() }}


Currently macros only work in the same template where they're defined


But why? I see that the function is created in the same compiled template.

edited Jan '15

Because a compiler is created per template and it keeps references to the macros created in the template itself.

Is it planned to support macros in included templates sometimes? In twig for example it works.