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>
impl<G: Html> Template<G>
sourcepub fn build(path: &str) -> TemplateInner<G>
pub fn build(path: &str) -> TemplateInner<G>
Creates a new TemplateInner
(a builder for Template
s). 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>>§
sourcepub fn get_path(&self) -> String
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.
sourcepub fn get_revalidate_interval(&self) -> Option<ComputedDuration>
pub fn get_revalidate_interval(&self) -> Option<ComputedDuration>
Gets the interval after which the template will next revalidate.
sourcepub fn revalidates(&self) -> bool
pub fn revalidates(&self) -> bool
Checks if this template can revalidate existing prerendered templates.
sourcepub fn revalidates_with_time(&self) -> bool
pub fn revalidates_with_time(&self) -> bool
Checks if this template can revalidate existing prerendered templates after a given time.
sourcepub fn revalidates_with_logic(&self) -> bool
pub fn revalidates_with_logic(&self) -> bool
Checks if this template can revalidate existing prerendered templates based on some given logic.
sourcepub fn uses_incremental(&self) -> bool
pub fn uses_incremental(&self) -> bool
Checks if this template can render more templates beyond those paths it explicitly defines.
sourcepub fn uses_build_paths(&self) -> bool
pub fn uses_build_paths(&self) -> bool
Checks if this template is a template to generate paths beneath it.
sourcepub fn uses_request_state(&self) -> bool
pub fn uses_request_state(&self) -> bool
Checks if this template needs to do anything on requests for it.
sourcepub fn uses_build_state(&self) -> bool
pub fn uses_build_state(&self) -> bool
Checks if this template needs to do anything at build time.
sourcepub fn can_amalgamate_states(&self) -> bool
pub fn can_amalgamate_states(&self) -> bool
Checks if this template has custom logic to amalgamate build and request states if both are generated.