@use std::borrow::Cow; @use validator::{ValidationErrors, ValidationErrorsKind}; @use crate::templates::base; @use crate::template_utils::*; @use crate::routes::user::NewUserForm; @use crate::routes::*; @(ctx: BaseContext, enabled: bool, form: &NewUserForm, errors: ValidationErrors) @:base(ctx, i18n!(ctx.1, "Create your account"), {}, {}, { @if enabled {

@i18n!(ctx.1, "Create an account")

@if let Some(ValidationErrorsKind::Field(errs)) = errors.clone().errors().get("__all__") {

@errs[0].message.as_ref().unwrap_or(&Cow::from("Unknown error"))

} @(Input::new("username", i18n!(ctx.1, "Username")) .default(&form.username) .error(&errors) .set_prop("minlength", 1) .html(ctx.1)) @(Input::new("email", i18n!(ctx.1, "Email")) .default(&form.email) .error(&errors) .set_prop("minlength", 1) .html(ctx.1)) @(Input::new("password", i18n!(ctx.1, "Password")) .default(&form.password) .error(&errors) .set_prop("minlength", 8) .input_type("password") .html(ctx.1)) @(Input::new("password_confirmation", i18n!(ctx.1, "Password confirmation")) .default(&form.password_confirmation) .error(&errors) .set_prop("minlength", 8) .input_type("password") .html(ctx.1))
} else {

@i18n!(ctx.1, "Apologies, but registrations are closed on this particular instance. You can, however, find a different one.")

} })