-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Template Rendering of a Result<T + Display, E + Display> Cleanly #1059
Comments
Have a look how to implement custom filters. Adding your own I wouldn't like askama to branch both cases automagically, because I would most like wrap the error message in e.g. |
I did attempt this but had compiler errors regarding sized types and another anomalous issues I couldn't resolve myself. I would accept this as a solution if I could manage it. |
A filter should definitely be possible. Do you have the exact error message? I don't think there's a general solution here because a blanket impl for A filter or macro definitely feels like the straightforward option here. |
I have a template that I call a View. It has implementations which return templates-in-templates with derived values. Sometimes these can fail and return results. These results need to be handled inside the template, even though both arms of Result<> implement Display.
My template could look like this:
Instead, it must look like this:
I don't like this. It would be super cool if there was a way to simply
{{ result }}
and render either branch automatically.The text was updated successfully, but these errors were encountered: