Skip to main content

TemplateData

Struct TemplateData 

Source
pub struct TemplateData<'a, A>
where A: Serialize,
{
Show 37 fields pub project: &'a str, pub author: &'a str, pub base_url: &'a str, pub twitter_username: &'a str, pub language_code: &'a str, pub country_code: &'a str, pub see_also: &'a [String], pub copyright_start: &'a str, pub description: &'a str, pub social_image: &'a str, pub social_image_alt: &'a str, pub style_sheets: Vec<&'a str>, pub scripts: Vec<&'a str>, pub page_name: &'a str, pub page_url: &'a str, pub robots: &'a str, pub og_type: &'static str, pub article: Option<&'a Article>, pub jsonld: Option<String>, pub display_name: String, pub canonical_url: String, pub locale: String, pub social_image_url: String, pub social_image_width: Option<u32>, pub social_image_height: Option<u32>, pub social_image_type: Option<&'static str>, pub has_svg_icon: bool, pub preconnect: Vec<String>, pub copyright_end: i32, pub color_scheme: &'static str, pub theme_colors: Vec<ThemeColorTag>, pub theme_script: &'a str, pub analytics: Option<&'a AnalyticsPaths>, pub sentry_browser: Option<&'a SentryBrowser>, pub environment: Environment, pub cache_buster: &'a BTreeMap<String, String>, pub app: A,
}
Expand description

What Handlebars sees: base data, page data, what the server computed, and the caller’s own.

Borrowed throughout — nothing is copied that was not computed. A is the caller’s data, reachable in templates as {{app.…}}; pass () for none.

Fields§

§project: &'a str§author: &'a str§base_url: &'a str§twitter_username: &'a str§language_code: &'a str§country_code: &'a str§see_also: &'a [String]§copyright_start: &'a str§description: &'a str§social_image: &'a str

The path as declared, for a page that wants the asset itself — a CSS background, say. Use social_image_url for anything a crawler reads.

§social_image_alt: &'a str§style_sheets: Vec<&'a str>§scripts: Vec<&'a str>§page_name: &'a str§page_url: &'a str§robots: &'a str§og_type: &'static str

website, or article when the page carries article metadata.

§article: Option<&'a Article>§jsonld: Option<String>

Escaped for direct embedding in a <script> block.

§display_name: String

"{page_name} | {project}" — the <title>, always.

§canonical_url: String

"{base_url}{page_url}".

§locale: String

"{language_code}_{country_code}", for og:locale.

§social_image_url: String

Absolute and content-hashed. Open Graph requires an absolute URL: a crawler fetching the page in isolation cannot resolve a relative one, so a relative og:image silently yields no share card at all.

§social_image_width: Option<u32>§social_image_height: Option<u32>§social_image_type: Option<&'static str>§has_svg_icon: bool

Whether to link favicon.svg.

§preconnect: Vec<String>

Distinct cross-origin hosts referenced by the stylesheets and scripts below, so the connection is warm before the request that needs it.

§copyright_end: i32

Computed per render, never cached — a long-running server would otherwise keep claiming last year after New Year’s.

§color_scheme: &'static str§theme_colors: Vec<ThemeColorTag>§theme_script: &'a str§analytics: Option<&'a AnalyticsPaths>§sentry_browser: Option<&'a SentryBrowser>§environment: Environment§cache_buster: &'a BTreeMap<String, String>

Original asset path to content-hashed path.

§app: A

Implementations§

Source§

impl<'a, A> TemplateData<'a, A>
where A: Serialize,

Source

pub fn assemble( base: &'a BaseTemplateData, page: &'a PageTemplateData, frontend: Option<&'a FrontendRuntime>, environment: Environment, cache_buster: &'a BTreeMap<String, String>, app: A, ) -> Result<Self, TemplateError>

§Errors

TemplateError::JsonLd if the page’s JSON-LD document cannot be serialized.

Trait Implementations§

Source§

impl<'a, A> Debug for TemplateData<'a, A>
where A: Serialize + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, A> Serialize for TemplateData<'a, A>
where A: Serialize + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a, A> Freeze for TemplateData<'a, A>
where A: Freeze,

§

impl<'a, A> RefUnwindSafe for TemplateData<'a, A>
where A: RefUnwindSafe,

§

impl<'a, A> Send for TemplateData<'a, A>
where A: Send,

§

impl<'a, A> Sync for TemplateData<'a, A>
where A: Sync,

§

impl<'a, A> Unpin for TemplateData<'a, A>
where A: Unpin,

§

impl<'a, A> UnsafeUnpin for TemplateData<'a, A>
where A: UnsafeUnpin,

§

impl<'a, A> UnwindSafe for TemplateData<'a, A>
where A: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ServiceExt for T

Source§

fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>
where Self: Sized,

Propagate a header from the request to the response. Read more
Source§

fn add_extension<T>(self, value: T) -> AddExtension<Self, T>
where Self: Sized,

Add some shareable value to request extensions. Read more
Source§

fn map_request_body<F>(self, f: F) -> MapRequestBody<Self, F>
where Self: Sized,

Apply a transformation to the request body. Read more
Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
Source§

fn compression(self) -> Compression<Self>
where Self: Sized,

Compresses response bodies. Read more
Source§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
Source§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

fn sensitive_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>
where Self: Sized,

Mark headers as sensitive on both requests and responses. Read more
Source§

fn sensitive_request_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<Self>
where Self: Sized,

Mark headers as sensitive on requests. Read more
Source§

fn sensitive_response_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveResponseHeaders<Self>
where Self: Sized,

Mark headers as sensitive on responses. Read more
Source§

fn override_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request. Read more
Source§

fn append_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Append a header into the request. Read more
Source§

fn insert_request_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request, if the header is not already present. Read more
Source§

fn override_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response. Read more
Source§

fn append_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Append a header into the response. Read more
Source§

fn insert_response_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response, if the header is not already present. Read more
Source§

fn set_request_id<M>( self, header_name: HeaderName, make_request_id: M, ) -> SetRequestId<Self, M>
where Self: Sized, M: MakeRequestId,

Add request id header and extension. Read more
Source§

fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>
where Self: Sized, M: MakeRequestId,

Add request id header and extension, using x-request-id as the header name. Read more
Source§

fn propagate_request_id( self, header_name: HeaderName, ) -> PropagateRequestId<Self>
where Self: Sized,

Propgate request ids from requests to responses. Read more
Source§

fn propagate_x_request_id(self) -> PropagateRequestId<Self>
where Self: Sized,

Propgate request ids from requests to responses, using x-request-id as the header name. Read more
Source§

fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>
where Self: Sized,

Catch panics and convert them into 500 Internal Server responses. Read more
Source§

fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>
where Self: Sized,

Intercept requests with over-sized payloads and convert them into 413 Payload Too Large responses. Read more
Source§

fn trim_trailing_slash(self) -> NormalizePath<Self>
where Self: Sized,

Remove trailing slashes from paths. Read more
Source§

fn append_trailing_slash(self) -> NormalizePath<Self>
where Self: Sized,

Append trailing slash to paths. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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