feat(core): join safe html fragments

Let already-safe fragments compose without downgrading to String, and use it in the v0 page assembly example to keep rendered and lowered fragments typed at the boundary.

req: html_safety/001

req: html_safety/002

req: component/003
This commit is contained in:
slhx agent
2026-06-01 23:49:20 +02:00
parent fd5d48d59a
commit 117eb57179
4 changed files with 35 additions and 12 deletions
+14
View File
@@ -141,6 +141,20 @@ impl SafeHtml {
pub fn as_str(&self) -> &str {
&self.0
}
pub fn join(fragments: impl IntoIterator<Item = SafeHtml>) -> Self {
fragments.into_iter().collect()
}
}
impl FromIterator<SafeHtml> for SafeHtml {
fn from_iter<T: IntoIterator<Item = SafeHtml>>(iter: T) -> Self {
let mut html = String::new();
for fragment in iter {
html.push_str(fragment.as_str());
}
Self(html)
}
}
impl AsRef<str> for SafeHtml {