reduce code repetition with class splices
This commit is contained in:
parent
b20822a644
commit
7d9bc2d7cd
|
@ -4,16 +4,18 @@ use maud::{html, Markup};
|
||||||
///
|
///
|
||||||
/// Render a flash elements based on the given flash name and message.
|
/// Render a flash elements based on the given flash name and message.
|
||||||
pub fn build_template(flash_name: &str, flash_msg: &str) -> Markup {
|
pub fn build_template(flash_name: &str, flash_msg: &str) -> Markup {
|
||||||
let flash_class = match flash_name {
|
let common_classes = "capsule center center-text flash-message font-normal ";
|
||||||
"success" => "capsule center-text flash-message font-normal border-success",
|
|
||||||
"info" => "capsule center-text flash-message font-normal border-info",
|
let border_class = match flash_name {
|
||||||
"warning" => "capsule center-text flash-message font-normal border-warning",
|
"success" => "border-success",
|
||||||
"error" => "capsule center-text flash-message font-normal border-danger",
|
"info" => "border-info",
|
||||||
|
"warning" => "border-warning",
|
||||||
|
"error" => "border-danger",
|
||||||
_ => "",
|
_ => "",
|
||||||
};
|
};
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
div class=(flash_class) {
|
div class={ (common_classes) (border_class) } {
|
||||||
(flash_msg)
|
(flash_msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue