Trait used to generate HTML from Rust structures
It contains the following optional definitions:
// Defaults to an empty string
;
// Defaults to empty vec
;
// Defaults to empty vec
;
// Calls `as_raw_html` for each of the items returned by `inner_html`
;
as well as the following definition which should not need to be implemented, but may on occasion be useful to be overridden:
Finally, the following may be called to get a structured js_sys type:
;
There are 3 other tools included in this crate:
- An
Htmlify
implementation for&str
. This is a special case which simply returns the string itself whenas_raw_html
is called, and returnsNone
whenas_element
is called. This is so text-content "leaves" can be represented. (and the default implementation ofas_element
understands this). - An
Attribute
struct to store key-value pairs as strings, used specifically for element attributes. These useCow<'static, str>
to leave optimization details up to the implementor. - An
append_to_document_body
function which takes anyimpl Htmlify
and attempts to append it to the document body (through web_sys calls). This is here purely for convenience.