pub struct Templates { /* private fields */ }Expand description
Wrapper around minijinja::Environment helping rendering the various
templates
Implementations§
Source§impl Templates
impl Templates
Sourcepub async fn load(
path: Utf8PathBuf,
url_builder: UrlBuilder,
vite_manifest_path: Option<Utf8PathBuf>,
translations_path: Utf8PathBuf,
branding: SiteBranding,
features: SiteFeatures,
strict: bool,
) -> Result<Self, TemplateLoadingError>
pub async fn load( path: Utf8PathBuf, url_builder: UrlBuilder, vite_manifest_path: Option<Utf8PathBuf>, translations_path: Utf8PathBuf, branding: SiteBranding, features: SiteFeatures, strict: bool, ) -> Result<Self, TemplateLoadingError>
Sourcepub async fn reload(&self) -> Result<(), TemplateLoadingError>
pub async fn reload(&self) -> Result<(), TemplateLoadingError>
Reload the templates on disk
§Errors
Returns an error if the templates could not be reloaded from disk.
Sourcepub fn translator(&self) -> Arc<Translator>
pub fn translator(&self) -> Arc<Translator>
Get the translator
Source§impl Templates
impl Templates
Sourcepub fn render_not_found(
&self,
context: &WithLanguage<NotFoundContext>,
) -> Result<String, TemplateError>
pub fn render_not_found( &self, context: &WithLanguage<NotFoundContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_app(
&self,
context: &WithLanguage<AppContext>,
) -> Result<String, TemplateError>
pub fn render_app( &self, context: &WithLanguage<AppContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_swagger(
&self,
context: &ApiDocContext,
) -> Result<String, TemplateError>
pub fn render_swagger( &self, context: &ApiDocContext, ) -> Result<String, TemplateError>
Sourcepub fn render_swagger_callback(
&self,
context: &ApiDocContext,
) -> Result<String, TemplateError>
pub fn render_swagger_callback( &self, context: &ApiDocContext, ) -> Result<String, TemplateError>
Sourcepub fn render_login(
&self,
context: &WithLanguage<WithCsrf<LoginContext>>,
) -> Result<String, TemplateError>
pub fn render_login( &self, context: &WithLanguage<WithCsrf<LoginContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_register(
&self,
context: &WithLanguage<WithCsrf<RegisterContext>>,
) -> Result<String, TemplateError>
pub fn render_register( &self, context: &WithLanguage<WithCsrf<RegisterContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_password_register(
&self,
context: &WithLanguage<WithCsrf<WithCaptcha<PasswordRegisterContext>>>,
) -> Result<String, TemplateError>
pub fn render_password_register( &self, context: &WithLanguage<WithCsrf<WithCaptcha<PasswordRegisterContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_register_steps_verify_email(
&self,
context: &WithLanguage<WithCsrf<RegisterStepsVerifyEmailContext>>,
) -> Result<String, TemplateError>
pub fn render_register_steps_verify_email( &self, context: &WithLanguage<WithCsrf<RegisterStepsVerifyEmailContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_register_steps_email_in_use(
&self,
context: &WithLanguage<RegisterStepsEmailInUseContext>,
) -> Result<String, TemplateError>
pub fn render_register_steps_email_in_use( &self, context: &WithLanguage<RegisterStepsEmailInUseContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_register_steps_display_name(
&self,
context: &WithLanguage<WithCsrf<RegisterStepsDisplayNameContext>>,
) -> Result<String, TemplateError>
pub fn render_register_steps_display_name( &self, context: &WithLanguage<WithCsrf<RegisterStepsDisplayNameContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_register_steps_registration_token(
&self,
context: &WithLanguage<WithCsrf<RegisterStepsRegistrationTokenContext>>,
) -> Result<String, TemplateError>
pub fn render_register_steps_registration_token( &self, context: &WithLanguage<WithCsrf<RegisterStepsRegistrationTokenContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_consent(
&self,
context: &WithLanguage<WithCsrf<WithSession<ConsentContext>>>,
) -> Result<String, TemplateError>
pub fn render_consent( &self, context: &WithLanguage<WithCsrf<WithSession<ConsentContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_policy_violation(
&self,
context: &WithLanguage<WithCsrf<WithSession<PolicyViolationContext>>>,
) -> Result<String, TemplateError>
pub fn render_policy_violation( &self, context: &WithLanguage<WithCsrf<WithSession<PolicyViolationContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_compat_login_policy_violation(
&self,
context: &WithLanguage<WithCsrf<WithSession<CompatLoginPolicyViolationContext>>>,
) -> Result<String, TemplateError>
pub fn render_compat_login_policy_violation( &self, context: &WithLanguage<WithCsrf<WithSession<CompatLoginPolicyViolationContext>>>, ) -> Result<String, TemplateError>
Render the compatibility login policy violation page
§Errors
Returns an error if the template fails to render.
Sourcepub fn render_sso_login(
&self,
context: &WithLanguage<WithCsrf<WithSession<CompatSsoContext>>>,
) -> Result<String, TemplateError>
pub fn render_sso_login( &self, context: &WithLanguage<WithCsrf<WithSession<CompatSsoContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_index(
&self,
context: &WithLanguage<WithCsrf<WithOptionalSession<IndexContext>>>,
) -> Result<String, TemplateError>
pub fn render_index( &self, context: &WithLanguage<WithCsrf<WithOptionalSession<IndexContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_recovery_start(
&self,
context: &WithLanguage<WithCsrf<RecoveryStartContext>>,
) -> Result<String, TemplateError>
pub fn render_recovery_start( &self, context: &WithLanguage<WithCsrf<RecoveryStartContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_recovery_progress(
&self,
context: &WithLanguage<WithCsrf<RecoveryProgressContext>>,
) -> Result<String, TemplateError>
pub fn render_recovery_progress( &self, context: &WithLanguage<WithCsrf<RecoveryProgressContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_recovery_finish(
&self,
context: &WithLanguage<WithCsrf<RecoveryFinishContext>>,
) -> Result<String, TemplateError>
pub fn render_recovery_finish( &self, context: &WithLanguage<WithCsrf<RecoveryFinishContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_recovery_expired(
&self,
context: &WithLanguage<WithCsrf<RecoveryExpiredContext>>,
) -> Result<String, TemplateError>
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.
Sourcepub fn render_recovery_consumed(
&self,
context: &WithLanguage<EmptyContext>,
) -> Result<String, TemplateError>
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.
Sourcepub fn render_recovery_disabled(
&self,
context: &WithLanguage<EmptyContext>,
) -> Result<String, TemplateError>
pub fn render_recovery_disabled( &self, context: &WithLanguage<EmptyContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_form_post<T: Serialize>(
&self,
context: &WithLanguage<FormPostContext<T>>,
) -> Result<String, TemplateError>
pub fn render_form_post<T: Serialize>( &self, context: &WithLanguage<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.
Sourcepub fn render_error(
&self,
context: &ErrorContext,
) -> Result<String, TemplateError>
pub fn render_error( &self, context: &ErrorContext, ) -> Result<String, TemplateError>
Sourcepub fn render_email_recovery_txt(
&self,
context: &WithLanguage<EmailRecoveryContext>,
) -> Result<String, TemplateError>
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.
Sourcepub fn render_email_recovery_html(
&self,
context: &WithLanguage<EmailRecoveryContext>,
) -> Result<String, TemplateError>
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.
Sourcepub fn render_email_recovery_subject(
&self,
context: &WithLanguage<EmailRecoveryContext>,
) -> Result<String, TemplateError>
pub fn render_email_recovery_subject( &self, context: &WithLanguage<EmailRecoveryContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_email_verification_txt(
&self,
context: &WithLanguage<EmailVerificationContext>,
) -> Result<String, TemplateError>
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.
Sourcepub fn render_email_verification_html(
&self,
context: &WithLanguage<EmailVerificationContext>,
) -> Result<String, TemplateError>
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.
Sourcepub fn render_email_verification_subject(
&self,
context: &WithLanguage<EmailVerificationContext>,
) -> Result<String, TemplateError>
pub fn render_email_verification_subject( &self, context: &WithLanguage<EmailVerificationContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_upstream_oauth2_link_mismatch(
&self,
context: &WithLanguage<WithCsrf<WithSession<UpstreamExistingLinkContext>>>,
) -> Result<String, TemplateError>
pub fn render_upstream_oauth2_link_mismatch( &self, context: &WithLanguage<WithCsrf<WithSession<UpstreamExistingLinkContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_upstream_oauth2_suggest_link(
&self,
context: &WithLanguage<WithCsrf<WithSession<UpstreamSuggestLink>>>,
) -> Result<String, TemplateError>
pub fn render_upstream_oauth2_suggest_link( &self, context: &WithLanguage<WithCsrf<WithSession<UpstreamSuggestLink>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_upstream_oauth2_do_register(
&self,
context: &WithLanguage<WithCsrf<UpstreamRegister>>,
) -> Result<String, TemplateError>
pub fn render_upstream_oauth2_do_register( &self, context: &WithLanguage<WithCsrf<UpstreamRegister>>, ) -> Result<String, TemplateError>
Sourcepub fn render_device_link(
&self,
context: &WithLanguage<DeviceLinkContext>,
) -> Result<String, TemplateError>
pub fn render_device_link( &self, context: &WithLanguage<DeviceLinkContext>, ) -> Result<String, TemplateError>
Sourcepub fn render_device_consent(
&self,
context: &WithLanguage<WithCsrf<WithSession<DeviceConsentContext>>>,
) -> Result<String, TemplateError>
pub fn render_device_consent( &self, context: &WithLanguage<WithCsrf<WithSession<DeviceConsentContext>>>, ) -> Result<String, TemplateError>
Sourcepub fn render_account_deactivated(
&self,
context: &WithLanguage<WithCsrf<AccountInactiveContext>>,
) -> Result<String, TemplateError>
pub fn render_account_deactivated( &self, context: &WithLanguage<WithCsrf<AccountInactiveContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_account_locked(
&self,
context: &WithLanguage<WithCsrf<AccountInactiveContext>>,
) -> Result<String, TemplateError>
pub fn render_account_locked( &self, context: &WithLanguage<WithCsrf<AccountInactiveContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_account_logged_out(
&self,
context: &WithLanguage<WithCsrf<AccountInactiveContext>>,
) -> Result<String, TemplateError>
pub fn render_account_logged_out( &self, context: &WithLanguage<WithCsrf<AccountInactiveContext>>, ) -> Result<String, TemplateError>
Sourcepub fn render_device_name(
&self,
context: &WithLanguage<DeviceNameContext>,
) -> Result<String, TemplateError>
pub fn render_device_name( &self, context: &WithLanguage<DeviceNameContext>, ) -> Result<String, TemplateError>
Render the automatic device name for OAuth 2.0 client
§Errors
Returns an error if the template fails to render.
Source§impl Templates
impl Templates
Sourcepub fn check_render<R: Rng + Clone>(
&self,
now: DateTime<Utc>,
rng: &R,
) -> Result<BTreeMap<(&'static str, SampleIdentifier), String>>
pub fn check_render<R: Rng + Clone>( &self, now: DateTime<Utc>, rng: &R, ) -> Result<BTreeMap<(&'static str, SampleIdentifier), String>>
Render all templates with the generated samples to check if they render properly.
Returns the renders in a map whose keys are template names and the values are lists of renders (according to the list of samples). Samples are stable across re-runs and can be used for acceptance testing.
§Errors
Returns an error if any of the templates fails to render
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Templates
impl !RefUnwindSafe for Templates
impl Send for Templates
impl Sync for Templates
impl Unpin for Templates
impl UnsafeUnpin for Templates
impl !UnwindSafe for Templates
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);