Skip to content

Fix jinja macro arguments handling#709

Merged
GuillaumeGomez merged 2 commits intoaskama-rs:mainfrom
GuillaumeGomez:fix-jinja-macro-args
Mar 18, 2026
Merged

Fix jinja macro arguments handling#709
GuillaumeGomez merged 2 commits intoaskama-rs:mainfrom
GuillaumeGomez:fix-jinja-macro-args

Conversation

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator

Fixes #707.

I simplified the logic a bit by first storing all arguments value (their expr in short), and then loop through them to generate the bindings. Since pretty much all arguments "passing" validity is checked in askama_parser, I could remove a lot of checks too.

Comment thread askama_derive/src/generator/helpers/macro_invocation.rs Dismissed
@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

Ah, new nightly fmt changes. Updated locally and fixed formatting.

Comment on lines +121 to +122
// FIXME: Too many steps to get a string. Also, `visit_associated_item` returns
// stuff like `x.y`, how is this supposed to match a variable? O.o
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same exact thought some time back, too, but then I was too lazy to refactor the code. :D

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehehe. We'll get to it at some point.

I think we're getting close enough for a new major release once a few more things are merged. :)

Copy link
Copy Markdown
Member

@Kijewski Kijewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@GuillaumeGomez GuillaumeGomez merged commit 9eed3ba into askama-rs:main Mar 18, 2026
50 checks passed
@GuillaumeGomez GuillaumeGomez deleted the fix-jinja-macro-args branch March 18, 2026 18:52
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.

Named macro arguments incorrectly resolved when optional parameter is skipped out of declaration order

3 participants