Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Macro that invokes other macros does not work when imported #330

Open
jjkavalam opened this issue Feb 8, 2023 · 2 comments
Open

Macro that invokes other macros does not work when imported #330

jjkavalam opened this issue Feb 8, 2023 · 2 comments

Comments

@jjkavalam
Copy link

jjkavalam commented Feb 8, 2023

Version: github.com/flosch/pongo2/v6 v6.0.0

Background

I have a macro main which i want to use in my templates. To implement this macro, i rely on child macros -child.

{% macro child() %}Child{% endmacro %}

{% macro main() export %}Main calls {{ child() }}{% endmacro %}

What is the issue

main does not work correctly when imported.

How to reproduce ?

  1. Create macros.j2 with the contents above.

  2. Create test1.j2 with the following contents:

{# filename: test1.j2 #}

{% import "macros.j2" main %}

{{ main() }}
  1. Render test1.j2 using the default options. We get the following output:
Main calls 

Expected output:

Main calls Child

Other details (may be useful)

When the macro is called from the same file such as below, we get the expected output:

{# filename: test2.j2 #}

{# macro definition above is pasted here #}

{{ main() }}
@jjkavalam jjkavalam changed the title Macro does not work when imported Macro that invokes other macros does not work when imported Feb 8, 2023
@jjkavalam
Copy link
Author

jjkavalam commented Feb 8, 2023

#331 contains a working solution

jjkavalam added a commit to jjkavalam/pongo2 that referenced this issue Feb 12, 2023
This was referenced Feb 12, 2023
@SharkFourSix
Copy link

Bump: Still facing this issue with exactly the same setup as above. In my main macro, I can receive variables fine. The child macro behaves as if it doesn't exist. Even outputing raw text it doesn't write to the client browser.

image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants