🦺 Modifica tipos para atributos HTML a minúsculas
This commit is contained in:
parent
8b06b1752a
commit
97581659bf
3 changed files with 10 additions and 7 deletions
|
@ -7,6 +7,7 @@ use crate::{builder_fn, AutoDefault};
|
|||
/// # Normalización
|
||||
///
|
||||
/// - Se eliminan los espacios al principio y al final.
|
||||
/// - Se convierte a minúsculas.
|
||||
/// - Se sustituyen los espacios intermedios por guiones bajos (`_`).
|
||||
/// - Si el resultado es una cadena vacía, se guarda `None`.
|
||||
///
|
||||
|
@ -15,7 +16,7 @@ use crate::{builder_fn, AutoDefault};
|
|||
/// ```rust
|
||||
/// use pagetop::prelude::*;
|
||||
///
|
||||
/// let id = OptionId::new("main section");
|
||||
/// let id = OptionId::new(" main Section ");
|
||||
/// assert_eq!(id.get(), Some(String::from("main_section")));
|
||||
///
|
||||
/// let empty = OptionId::default();
|
||||
|
@ -39,7 +40,7 @@ impl OptionId {
|
|||
/// El valor se normaliza automáticamente.
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl AsRef<str>) -> Self {
|
||||
let value = value.as_ref().trim().replace(' ', "_");
|
||||
let value = value.as_ref().trim().to_ascii_lowercase().replace(' ', "_");
|
||||
self.0 = (!value.is_empty()).then_some(value);
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue