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

Parse tuple expressions #608

Merged
merged 1 commit into from
Jan 28, 2022
Merged

Parse tuple expressions #608

merged 1 commit into from
Jan 28, 2022

Conversation

Kijewski
Copy link
Collaborator

Askama understands how to destructure tuples in let and match
statements, but it does not understand how to build a tuple.

This PR fixes this shortcoming.

@Kijewski
Copy link
Collaborator Author

I think this would resolve #607 quite nicely. It would compile the example to ↓, which is reasonably similar to what you would write by hand:

match &(
    self.client.can_post(&(self.post)),
    self.client.can_update(&(self.post)),
) {
    (false, false) => {
        writer.write_str("No!")?;
    }
    (can_post, can_update) => {
        writer.write_str("<ul>")?;
        if *(&(can_post) as &bool) {
            writer.write_str("<li>post</li>")?;
        }
        if *(&(can_update) as &bool) {
            writer.write_str("<li>update</li>")?;
        }
        writer.write_str("</ul>")?;
    }
}

Askama understands how to destructure tuples in let and match
statements, but it does not understand how to build a tuple.

This PR fixes this shortcoming.
Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Kijewski
Copy link
Collaborator Author

You're welcome :)

@djc djc merged commit da0b6ea into rinja-rs:main Jan 28, 2022
@Kijewski Kijewski deleted the pr-tuples branch January 28, 2022 10:23
@djc djc mentioned this pull request Feb 26, 2023
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.

2 participants