Fix hydration for static text nodes at the root of the template (#2184)

* Fix hydration for static text nodes at the root of the template

* fix clippy
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-03-29 18:22:55 -07:00
1 parent 4a622348f2
commit 6a781af693
3 files changed
+15 -1

No files matched your search

+9
View File
@@ -156,11 +156,20 @@ impl StringCache {
cur_path.pop();
}
TemplateNode::Text { text } => {
// write the id if we are prerendering and this is a root node that may need to be removed in the future
if prerender && is_root {
write!(chain, "<!--node-id")?;
chain.segments.push(Segment::RootNodeMarker);
write!(chain, "-->")?;
}
write!(
chain,
"{}",
askama_escape::escape(text, askama_escape::Html)
)?;
if prerender && is_root {
write!(chain, "<!--#-->")?;
}
}
TemplateNode::Dynamic { id: idx } | TemplateNode::DynamicText { id: idx } => {
chain.segments.push(Segment::Node(*idx))