Skip to main content

update

Function update 

Source
pub fn update(target: &str, html: &str) -> String
Expand description

Builds a message that replaces the contents of the element with id target (htmx innerHTML).

The element itself stays; wrapping and escaping work as in append. To replace a whole element, broadcast its new HTML with the same id instead.

ยงExamples

assert_eq!(
    ocre::realtime::update("post_count", "3 posts"),
    "<div hx-swap-oob=\"innerHTML:#post_count\">3 posts</div>"
);