Skip to content

Conversation

@StratusFearMe21
Copy link

@StratusFearMe21 StratusFearMe21 commented Nov 11, 2025

This PR adds the html_render macro to this crate which produces a struct that is able to both render to a pre-existing buffer, and also be passed into another invocation of html and render inside of that without allocating a new buffer.

Here's the documentation I created for the new html_render macro:

Functionally the same as [html] but produces a struct that implements [Render].

You can

  • Call render() to render the HTML as [Markup]
  • Call render_to() to render the HTML to a pre-existing &mut String
  • Pass this directly into an [html] invocation to add it as a component without allocating a new buffer.
use maud::{html, html_render, DOCTYPE};

let component = html_render! {
   p { "Wow, such component!" }
};

let full = html! {
   (DOCTYPE)
   head {}
   html {
       (component)
   }
};

This PR resolves #381 and #90

@StratusFearMe21
Copy link
Author

The performance wins are indeed significant

image

@StratusFearMe21 StratusFearMe21 changed the title Add macro which uses pre-existing buffer for rendering Add macro which uses pre-existing buffer for rendering (fix #381 #90) Nov 11, 2025
@StratusFearMe21 StratusFearMe21 changed the title Add macro which uses pre-existing buffer for rendering (fix #381 #90) Add macro which uses pre-existing buffer for rendering (fix #381) Nov 11, 2025
@StratusFearMe21 StratusFearMe21 changed the title Add macro which uses pre-existing buffer for rendering (fix #381) Add macro which uses pre-existing buffer for rendering (fixes #381) Nov 11, 2025
@StratusFearMe21 StratusFearMe21 changed the title Add macro which uses pre-existing buffer for rendering (fixes #381) Add macro which uses pre-existing buffer for rendering Nov 11, 2025
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.

Make nested html! invocations lazy

1 participant