Struct mas_templates::Templates

source ·
pub struct Templates { /* private fields */ }
Expand description

Wrapper around minijinja::Environment helping rendering the various templates

Implementations§

source§

impl Templates

source

pub async fn load( path: Utf8PathBuf, url_builder: UrlBuilder, vite_manifest_path: Utf8PathBuf, translations_path: Utf8PathBuf, branding: SiteBranding, features: SiteFeatures, ) -> Result<Self, TemplateLoadingError>

Load the templates from the given config

source

pub async fn reload(&self) -> Result<(), TemplateLoadingError>

Reload the templates on disk

source

pub fn translator(&self) -> Arc<Translator>

Get the translator

source§

impl Templates

source

pub fn render_not_found( &self, context: &WithLanguage<NotFoundContext>, ) -> Result<String, TemplateError>

Render the not found fallback page

§Errors

Returns an error if the template fails to render.

source

pub fn render_app( &self, context: &WithLanguage<AppContext>, ) -> Result<String, TemplateError>

Render the frontend app

§Errors

Returns an error if the template fails to render.

source

pub fn render_swagger( &self, context: &ApiDocContext, ) -> Result<String, TemplateError>

Render the Swagger API reference

§Errors

Returns an error if the template fails to render.

source

pub fn render_swagger_callback( &self, context: &ApiDocContext, ) -> Result<String, TemplateError>

Render the Swagger OAuth2 callback page

§Errors

Returns an error if the template fails to render.

source

pub fn render_login( &self, context: &WithLanguage<WithCsrf<LoginContext>>, ) -> Result<String, TemplateError>

Render the login page

§Errors

Returns an error if the template fails to render.

source

pub fn render_register( &self, context: &WithLanguage<WithCsrf<WithCaptcha<RegisterContext>>>, ) -> Result<String, TemplateError>

Render the registration page

§Errors

Returns an error if the template fails to render.

Render the client consent page

§Errors

Returns an error if the template fails to render.

source

pub fn render_policy_violation( &self, context: &WithLanguage<WithCsrf<WithSession<PolicyViolationContext>>>, ) -> Result<String, TemplateError>

Render the policy violation page

§Errors

Returns an error if the template fails to render.

source

pub fn render_sso_login( &self, context: &WithLanguage<WithCsrf<WithSession<CompatSsoContext>>>, ) -> Result<String, TemplateError>

Render the legacy SSO login consent page

§Errors

Returns an error if the template fails to render.

source

pub fn render_index( &self, context: &WithLanguage<WithCsrf<WithOptionalSession<IndexContext>>>, ) -> Result<String, TemplateError>

Render the home page

§Errors

Returns an error if the template fails to render.

source

pub fn render_account_verify_email( &self, context: &WithLanguage<WithCsrf<WithSession<EmailVerificationPageContext>>>, ) -> Result<String, TemplateError>

Render the email verification page

§Errors

Returns an error if the template fails to render.

source

pub fn render_account_add_email( &self, context: &WithLanguage<WithCsrf<WithSession<EmailAddContext>>>, ) -> Result<String, TemplateError>

Render the email verification page

§Errors

Returns an error if the template fails to render.

source

pub fn render_recovery_start( &self, context: &WithLanguage<WithCsrf<RecoveryStartContext>>, ) -> Result<String, TemplateError>

Render the account recovery start page

§Errors

Returns an error if the template fails to render.

source

pub fn render_recovery_progress( &self, context: &WithLanguage<WithCsrf<RecoveryProgressContext>>, ) -> Result<String, TemplateError>

Render the account recovery start page

§Errors

Returns an error if the template fails to render.

source

pub fn render_recovery_finish( &self, context: &WithLanguage<WithCsrf<RecoveryFinishContext>>, ) -> Result<String, TemplateError>

Render the account recovery finish page

§Errors

Returns an error if the template fails to render.

source

pub fn render_recovery_expired( &self, context: &WithLanguage<WithCsrf<RecoveryExpiredContext>>, ) -> Result<String, TemplateError>

Render the account recovery link expired page

§Errors

Returns an error if the template fails to render.

source

pub fn render_recovery_consumed( &self, context: &WithLanguage<EmptyContext>, ) -> Result<String, TemplateError>

Render the account recovery link consumed page

§Errors

Returns an error if the template fails to render.

source

pub fn render_recovery_disabled( &self, context: &WithLanguage<EmptyContext>, ) -> Result<String, TemplateError>

Render the account recovery disabled page

§Errors

Returns an error if the template fails to render.

source

pub fn render_reauth( &self, context: &WithLanguage<WithCsrf<WithSession<ReauthContext>>>, ) -> Result<String, TemplateError>

Render the re-authentication form

§Errors

Returns an error if the template fails to render.

source

pub fn render_form_post<T: Serialize>( &self, context: &FormPostContext<T>, ) -> Result<String, TemplateError>

Render the form used by the form_post response mode

§Errors

Returns an error if the template fails to render.

source

pub fn render_error( &self, context: &ErrorContext, ) -> Result<String, TemplateError>

Render the HTML error page

§Errors

Returns an error if the template fails to render.

source

pub fn render_email_recovery_txt( &self, context: &WithLanguage<EmailRecoveryContext>, ) -> Result<String, TemplateError>

Render the email recovery email (plain text variant)

§Errors

Returns an error if the template fails to render.

source

pub fn render_email_recovery_html( &self, context: &WithLanguage<EmailRecoveryContext>, ) -> Result<String, TemplateError>

Render the email recovery email (HTML text variant)

§Errors

Returns an error if the template fails to render.

source

pub fn render_email_recovery_subject( &self, context: &WithLanguage<EmailRecoveryContext>, ) -> Result<String, TemplateError>

Render the email recovery subject

§Errors

Returns an error if the template fails to render.

source

pub fn render_email_verification_txt( &self, context: &WithLanguage<EmailVerificationContext>, ) -> Result<String, TemplateError>

Render the email verification email (plain text variant)

§Errors

Returns an error if the template fails to render.

source

pub fn render_email_verification_html( &self, context: &WithLanguage<EmailVerificationContext>, ) -> Result<String, TemplateError>

Render the email verification email (HTML text variant)

§Errors

Returns an error if the template fails to render.

source

pub fn render_email_verification_subject( &self, context: &WithLanguage<EmailVerificationContext>, ) -> Result<String, TemplateError>

Render the email verification subject

§Errors

Returns an error if the template fails to render.

Render the upstream link mismatch message

§Errors

Returns an error if the template fails to render.

Render the upstream suggest link message

§Errors

Returns an error if the template fails to render.

source

pub fn render_upstream_oauth2_do_register( &self, context: &WithLanguage<WithCsrf<UpstreamRegister>>, ) -> Result<String, TemplateError>

Render the upstream register screen

§Errors

Returns an error if the template fails to render.

Render the device code link page

§Errors

Returns an error if the template fails to render.

Render the device code consent page

§Errors

Returns an error if the template fails to render.

source§

impl Templates

source

pub fn check_render(&self, now: DateTime<Utc>, rng: &mut impl Rng) -> Result<()>

Render all templates with the generated samples to check if they render properly

§Errors

Returns an error if any of the templates fails to render

Trait Implementations§

source§

impl Clone for Templates

source§

fn clone(&self) -> Templates

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Templates

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> Filterable for T

source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T
where T: Send + Sync,