Skip to main content

Module html

Module html 

Source
Expand description

HTML string helpers for plugins that mutate text/html responses.

§Layering

  1. String opsinject, inject_before, replace_once, replace_between (markers / anchors, no HTTP).
  2. Responsecrate::Response::map_buffered_html skips streams / non-HTML.
  3. Middlewarecrate::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§

HtmlInject
Options for inject.

Enums§

HtmlAnchor
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. Returns None when skipped or unchanged.
inject_after_open_tag
Insert fragment immediately after the first case-insensitive open tag needle (e.g. "<body" → after the closing > of that tag).
inject_before
Insert fragment immediately before the first case-insensitive needle.
inject_body_end
Convenience: before </body> with marker.
inject_head
Convenience: head inject with marker.
replace_between
Replace content between start_marker and end_marker (exclusive markers kept).
replace_once
Replace the first occurrence of from with to (case-sensitive).