Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for recursive macros #133

Merged
merged 9 commits into from
Nov 3, 2022

Conversation

SergioBenitez
Copy link
Contributor

As in the title. Fixes #129. Note that the changes to meta.rs are not actually necessary - they formed part of an earlier attempt but I decided to keep them here as being able to reference the macro seems like it might be useful in the future. Happy to move those changes.

@mitsuhiko
Copy link
Owner

Thank you! Sorry I pushed up a few changes to undo the meta.rs so that it gets easier to review. I think the issue here is that at the time of the context lookup the assumption is made that the macro is reachable under that name which however is not necessarily true. Take this for instance:

{% from "helpers.html" import recursive_macro as foo %}
{{ foo() }}}

It would try to look up recursive_macro in the current scope but it cannot be found under that name here. Annoyingly the receiver for call is &self which means we cannot easily put the macro into the context.

I changed it now but there is an awful lot of Arcing going on so I want to check first if that can be avoided.

@mitsuhiko mitsuhiko merged commit b16ac7a into mitsuhiko:main Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Macro cannot call itself recursively
2 participants