-
Notifications
You must be signed in to change notification settings - Fork 33
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
Can't pass Content argument to next template #134
Comments
Yes, I have also seen some problem related to this in the last release, after merging #125 . @kornelski , could you take a look at this, could the type for |
The problem here is that So when calling a template, there needs to be something anti-by-ref that decreases levels of indirection. This hack works:
Here's a minimal example: use std::io::{self, Write};
pub fn contentcall_html<W>(#[allow(unused_mut)] mut _ructe_out_: W, content: impl FnOnce(&mut W) -> io::Result<()>) -> io::Result<()>
where W: Write {
contentcallnext_html(_ructe_out_.by_ref(), |w| content(*w))?;
Ok(())
}
pub fn contentcallnext_html<W>(#[allow(unused_mut)] mut _ructe_out_: W, content: impl FnOnce(&mut W) -> io::Result<()>) -> io::Result<()>
where W: Write {
content(_ructe_out_.by_ref())?;
Ok(())
} @kaj Are you able to detect when argument to |
I wonder if ructe could define its own trait that calls things, so that dealing with |
Another workaround is to change the
I'm considering wether I shold document this a required workaround or basically revert #125 , as I still havn't found any other solution. |
I am happy with a the workaround. |
Gave up on finding a real fix for #134, so documenting a workaround instead.
* The main branch in git is now `main` rather than `master`. * Update clippy lint usage to get rid of warnings in all code using ructe (PR #137). Thanks @vbradl! * Identified a problem with `Content` parameters sent through intermediate templates, and documented a workaround for it (Issue #134, PR #141). Thanks @drehren and @kornelski. * The `axum` test is mentioned in [`README.md`] (PR #138). Thanks @abd0-omar! * Update `base64` to 0.22.1 and `itertools` dependency to 0.13.0. * MSRV is now 1.61.0.
Hi, consider the following two templates
first_template.rs.html:
next_template.rs.html:
Compilation fails with the following:
Is it possible to pass Content from a template to the next ?
Thanks !
The text was updated successfully, but these errors were encountered: