When using macros within templates, I’ve noticed a difference in behaviour compared to when they are used inside a shortcode.
Consider the following macro structure:
├── templates/
│ ├── macros
│ │ ├── first_macro.html
│ │ └── second_macro.html
In second_macro.html
, there is a reference to first_macro.html
without an explicit import:
{%- set first_macro = first_macro::macro_action() -%}
Both macros are imported in base.html
, and when used within templates, everything works fine. However, when calling second_macro.html
from a shortcode, an error occurs stating that first_macro.html
cannot be found despite both macros being imported at the beginning of the shortcode.
Error: Reason: Failed to render 'shortcodes/books.md': error while rendering macro `first_macro::macro_action`
Error: Reason: Macro namespace `first_macro` was not found in template `macros/second_macro.html`. Have you maybe forgotten to import it, or misspelled it?
If I explicitly import first_macro.html
inside second_macro.html
, the error disappears.
Is this the expected behavior? Or could this be a limitation or bug in Zola/Tera?