Expand description
HTML string helpers for plugins that mutate text/html responses.
§Layering
- String ops —
inject,inject_before,replace_once,replace_between(markers / anchors, no HTTP). - Response —
crate::Response::map_buffered_htmlskips streams / non-HTML. - Middleware —
crate::middleware::before/ [after] / [around] / [map_html] for request/response hooks around the whole chain.
Prefer markers (<!-- plugin -->) so stacked injects stay idempotent.
Template-slot style edits: put <!--slot:name-->…<!--/slot:name--> in the
document and use replace_between.
Structs§
- Html
Inject - Options for
inject.
Enums§
- Html
Anchor - Where to place a fragment inside an HTML document.
Functions§
- find_ci
- Case-insensitive substring search; returns byte index in
hay(ASCII tags). - inject
- Apply
HtmlInject. ReturnsNonewhen skipped or unchanged. - inject_
after_ open_ tag - Insert
fragmentimmediately after the first case-insensitive open tagneedle(e.g."<body"→ after the closing>of that tag). - inject_
before - Insert
fragmentimmediately before the first case-insensitiveneedle. - inject_
body_ end - Convenience: before
</body>with marker. - inject_
head - Convenience: head inject with marker.
- replace_
between - Replace content between
start_markerandend_marker(exclusive markers kept). - replace_
once - Replace the first occurrence of
fromwithto(case-sensitive).