Struct perseus::template::Template

source ·
pub struct Template<G: Html> { /* private fields */ }
Expand description

A single template in an app. Each template is comprised of a Sycamore view, a state type, and some functions involved with generating that state. Pages can then be generated from particular states. For instance, a single docs template could have a state struct that stores a title and some content, which could then render as many pages as desired.

You can read more about the templates system here.

Implementations§

source§

impl<G: Html> Template<G>

source

pub fn build(path: &str) -> TemplateInner<G>

Creates a new TemplateInner (a builder for Templates). By default, this has absolutely no associated data, and, if rendered, it would result in a blank screen. You can call methods like .view() on this, and you should eventually call .build() to turn it into a full template.

Methods from Deref<Target = TemplateInner<G>>§

source

pub fn get_path(&self) -> String

Gets the path of the template. This is the root path under which any generated pages will be served. In the simplest case, there will only be one page rendered, and it will occupy that root position.

Note that this will automatically transform index to an empty string.

Note that this will prepend __capsule/ to any capsules automatically.

source

pub fn get_revalidate_interval(&self) -> Option<ComputedDuration>

Gets the interval after which the template will next revalidate.

source

pub fn revalidates(&self) -> bool

Checks if this template can revalidate existing prerendered templates.

source

pub fn revalidates_with_time(&self) -> bool

Checks if this template can revalidate existing prerendered templates after a given time.

source

pub fn revalidates_with_logic(&self) -> bool

Checks if this template can revalidate existing prerendered templates based on some given logic.

source

pub fn uses_incremental(&self) -> bool

Checks if this template can render more templates beyond those paths it explicitly defines.

source

pub fn uses_build_paths(&self) -> bool

Checks if this template is a template to generate paths beneath it.

source

pub fn uses_request_state(&self) -> bool

Checks if this template needs to do anything on requests for it.

source

pub fn uses_build_state(&self) -> bool

Checks if this template needs to do anything at build time.

source

pub fn can_amalgamate_states(&self) -> bool

Checks if this template has custom logic to amalgamate build and request states if both are generated.

source

pub fn is_basic(&self) -> bool

Checks if this template defines no rendering logic whatsoever. Such templates will be rendered using SSG. Basic templates can still modify headers (which could hypothetically be using global state that’s dependent on server-side generation).

Trait Implementations§

source§

impl<G: Debug + Html> Debug for Template<G>

source§

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

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

impl<G: Html> Deref for Template<G>

§

type Target = TemplateInner<G>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<G> !RefUnwindSafe for Template<G>

§

impl<G> Send for Template<G>

§

impl<G> Sync for Template<G>

§

impl<G> Unpin for Template<G>

§

impl<G> !UnwindSafe for Template<G>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.