You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnbody() -> Markup{ ...}html!{
h1 {"My page"}
main {(body())}}
There is technically no need for the intermediate buffer from body, because the markup could render directly into the outer buffer.
In my ideal API, Markup would just implement Render (the render method would have to return something other than Markup, probably just PreEscaped<String>) and take advantage of the existing render_to method.
/// Helper for writing nested html_to!/// Basically a lazy html! that can be rendered(-to) on demandmacro_rules! html_in {($($tt:tt)*) => {MaudFnWrapper(|buf:&mutString| maud::html_to!{ buf, $($tt)*})};}/// A bit of closure magic to work around nested html_to!structMaudFnWrapper<F>(F);impl<F>RenderforMaudFnWrapper<F>whereF:Fn(&mutString){fnrender_to(&self,buffer:&mutString){self.0(buffer)}}
Howerer this is mainly a workaround, than proper solution.
It's probably fine. I think I was originally concerned about ergonomics around lifetimes, but the fact that other libraries don't care, as well as improvements on the Rust side, makes that concern unfounded. We'll still need to decide between Fn / FnMove though, and I'd like to get #412 landed first.
Activity
nikvoid commentedon Jul 17, 2023
In my project (using #373) I solved it like this:
Howerer this is mainly a workaround, than proper solution.
mattfbacon commentedon Jul 17, 2023
Cool! I'll take a look at that and maybe make a PoC of my idea.
imbolc commentedon Oct 31, 2024
Implemented in Hypertext. How difficult would it be to use the same approach in Maud?
lambda-fairy commentedon Jan 6, 2025
It's probably fine. I think I was originally concerned about ergonomics around lifetimes, but the fact that other libraries don't care, as well as improvements on the Rust side, makes that concern unfounded. We'll still need to decide between
Fn/FnMovethough, and I'd like to get #412 landed first.StratusFearMe21 commentedon Nov 11, 2025
I just made a PR (#484) that would fix this