pub fn heading(
    level: Value,
    text: Value,
    id: Option<Value>
) -> Result<Value, Error>
Expand description

Make an html heading: h1, h2, h3 etc.

Example

use mailpot_web::minijinja_utils::heading;
use minijinja::value::Value;

assert_eq!(
  "<h1 id=\"bl-bfa-b-ah-b-asdb-hadas-d\">bl bfa B AH bAsdb hadas d<a class=\"self-link\" href=\"#bl-bfa-b-ah-b-asdb-hadas-d\"></a></h1>",
  &heading(1.into(), "bl bfa B AH bAsdb hadas d".into(), None).unwrap().to_string()
);
assert_eq!(
    "<h2 id=\"short\">bl bfa B AH bAsdb hadas d<a class=\"self-link\" href=\"#short\"></a></h2>",
    &heading(2.into(), "bl bfa B AH bAsdb hadas d".into(), Some("short".into())).unwrap().to_string()
);
assert_eq!(
    r#"invalid operation: first heading() argument must be an unsigned integer less than 7 and positive"#,
    &heading(0.into(), "bl bfa B AH bAsdb hadas d".into(), Some("short".into())).unwrap_err().to_string()
);
assert_eq!(
    r#"invalid operation: first heading() argument must be an unsigned integer less than 7 and positive"#,
    &heading(8.into(), "bl bfa B AH bAsdb hadas d".into(), Some("short".into())).unwrap_err().to_string()
);
assert_eq!(
    r#"invalid operation: first heading() argument is not an integer < 7 but of type sequence"#,
    &heading(Value::from(vec![Value::from(1)]), "bl bfa B AH bAsdb hadas d".into(), Some("short".into())).unwrap_err().to_string()
);