-
Notifications
You must be signed in to change notification settings - Fork 63
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 embed a variable of type DOMTree in html! macro #12
Comments
Oops, you're right, looks like it's only the text node that comes with an |
By the way, if you're wondering about the weird type error in your final example, see 270e3b5#diff-77e4a492dd719688667e179426fe4ba4R31 |
I'm hitting the (sort of) inverse of this problem in a couple projects I'm working on with typed-html! fn render_main() -> DOMTree<String> {
html!(
<html>
<head>
<title>"Rustaceans Unite!"</title>
</head>
<body>
{ render_body() }
</body>
</html>
)
}
fn render_body() -> DOMTree<String> {
html!(
<h1>"Hello, world!"</h1>
)
} This feels like a natural way to split up my conceptual components when rendering a bunch of static HTML, but the return type of I feel like |
I don't think this would ever be possible with the current design ( |
Ran into the same "issue", trying to split up my Neither are very elegant, I think, since you're constantly allocating heap objects in both cases, but at least the interface itself is a bit nicer if the former return type worked. |
One other thing that's somewhat related to this, is that it's impossible to use this technique for example, when you have a top-level html! {
<table>{ rows.iter().map(to_html) }</table>
} The
So I guess, in some way, for this to work, you'd have to have something like a "snippet" that can be included in an |
I was playing around with this library, which looks super cool. I'm excited to be able to have more validation in HTML. I was trying to compose a couple different chunks of HTML in the following manner:
But it seems like DOMTree doesn't implement IntoIterator properly to compose these, even though it seems like it should given that you can nest
html!()
calls. This is the error I get:I also tried to wrap it into
vec![body].into_iterator()
, giving a slightly different error:Is this something that is expected to work? Am I doing something wrong? Or is there some other way I should go about this sort of thing?
The text was updated successfully, but these errors were encountered: