Skip to main content

hidden_input

Function hidden_input 

Source
pub fn hidden_input(name: impl AsRef<str>, value: impl AsRef<str>) -> Element
Expand description

An <input type="hidden" name="…" value="…">: the shape of a CSRF token field.

The field name is the application’s (_csrf, authenticity_token, csrfmiddlewaretoken, …); Molt fixes none. The value is escaped like any attribute.

§Examples

use molt::prelude::*;
assert_eq!(
    hidden_input("_csrf", "t0ken").render(),
    r#"<input type="hidden" name="_csrf" value="t0ken">"#
);