Skip to main content

prepend

Function prepend 

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

Builds a message that inserts html at the start of the element with id target (htmx afterbegin).

Typical use: a new row at the top of a table body. Wrapping and escaping work as in append.

ยงExamples

assert_eq!(
    ocre::realtime::prepend("posts", "<tr id=\"post_3\"><td>Hi</td></tr>"),
    "<tbody hx-swap-oob=\"afterbegin:#posts\"><tr id=\"post_3\"><td>Hi</td></tr></tbody>"
);