hyaenidae/toolkit/templates/input.rs.html
2021-01-08 22:32:02 -06:00

72 lines
1.9 KiB
HTML

@use crate::Input;
@(input: &Input)
@match (input.value.as_ref(), input.placeholder.as_ref()) {
(Some(value), Some(placeholder)) => {
@if input.is_textarea() {
<textarea
class="@input.class_string()"
name="@input.name"
placeholder="@placeholder"
>
@value
</textarea>
} else {
<input
class="@input.class_string()"
type="@input.kind_str()"
name="@input.name"
value="@value"
placeholder="@placeholder"
/>
}
}
(Some(value), None) => {
@if input.is_textarea() {
<textarea
class="@input.class_string()"
name="@input.name"
>
@value
</textarea>
} else {
<input
class="@input.class_string()"
type="@input.kind_str()"
name="@input.name"
value="@value"
/>
}
}
(None, Some(placeholder)) => {
@if input.is_textarea() {
<textarea
class="@input.class_string()"
name="@input.name"
placeholder="@placeholder"
></textarea>
} else {
<input
class="@input.class_string()"
type="@input.kind_str()"
name="@input.name"
placeholder="@placeholder"
/>
}
}
(None, None) => {
@if input.is_textarea() {
<textarea
class="@input.class_string()"
name="@input.name"
></textarea>
} else {
<input
class="@input.class_string()"
type="@input.kind_str()"
name="@input.name"
/>
}
}
}