🏷️Nuevo tipo "NameValue" para atributo "name"
This commit is contained in:
parent
12d79c8437
commit
420b17bb83
4 changed files with 42 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ pub_handle!(COMPONENT_HIDDEN);
|
|||
#[derive(Default)]
|
||||
pub struct Hidden {
|
||||
weight: isize,
|
||||
name : IdentifierValue,
|
||||
name : NameValue,
|
||||
value : AttributeValue,
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ impl Hidden {
|
|||
|
||||
// Hidden GETTERS.
|
||||
|
||||
pub fn name(&self) -> &IdentifierValue {
|
||||
pub fn name(&self) -> &NameValue {
|
||||
&self.name
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub struct Input {
|
|||
renderable : Renderable,
|
||||
classes : Classes,
|
||||
input_type : InputType,
|
||||
name : IdentifierValue,
|
||||
name : NameValue,
|
||||
value : AttributeValue,
|
||||
label : AttributeValue,
|
||||
size : Option<u16>,
|
||||
|
|
@ -369,7 +369,7 @@ impl Input {
|
|||
&self.input_type
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &IdentifierValue {
|
||||
pub fn name(&self) -> &NameValue {
|
||||
&self.name
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,14 @@ pub use assets::Assets;
|
|||
mod favicon;
|
||||
pub use favicon::Favicon;
|
||||
|
||||
mod attribute;
|
||||
pub use attribute::AttributeValue;
|
||||
|
||||
mod identifier;
|
||||
pub use identifier::IdentifierValue;
|
||||
|
||||
mod name;
|
||||
pub use name::NameValue;
|
||||
|
||||
mod attribute;
|
||||
pub use attribute::AttributeValue;
|
||||
|
||||
mod classes;
|
||||
pub use classes::{Classes, ClassesOp};
|
||||
|
|
|
|||
32
pagetop/src/html/name.rs
Normal file
32
pagetop/src/html/name.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#[derive(Default)]
|
||||
pub struct NameValue(String);
|
||||
|
||||
impl NameValue {
|
||||
pub fn new() -> Self {
|
||||
NameValue::default()
|
||||
}
|
||||
|
||||
// NameValue BUILDER.
|
||||
|
||||
pub fn with_value(mut self, value: &str) -> Self {
|
||||
self.alter_value(value);
|
||||
self
|
||||
}
|
||||
|
||||
// NameValue ALTER.
|
||||
|
||||
pub fn alter_value(&mut self, value: &str) -> &mut Self {
|
||||
self.0 = value.trim().replace(' ', "_");
|
||||
self
|
||||
}
|
||||
|
||||
// NameValue GETTERS.
|
||||
|
||||
pub fn get(&self) -> Option<String> {
|
||||
if self.0.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.0.to_owned())
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue