pub fn inject_before_body_close_or_append(html: &str, payload: &str) -> StringExpand description
Injects payload before </body>, appending it when there is none.
Six call sites across islands, view_transitions and search each
wrote this by hand as rfind("</body>") with an append fallback. The
fallback matters — HTML allows the end tag to be omitted, and the parser
fires no handler then — so it is stated once here rather than six times.
§Examples
use ssg::util::html_rewriter::inject_before_body_close_or_append;
let out = inject_before_body_close_or_append("<html><body><p>x", "<i>y</i>");
assert!(out.ends_with("<i>y</i>"), "no </body>, so appended: {out}");