Module perseus::templates[][src]

Expand description

Utilities for developing templates, particularly including return types for various rendering strategies.

Re-exports

pub use crate::errors::ErrorCause;
pub use crate::errors::GenericErrorWithCause;

Macros

Gets a HashMap of the given templates by their paths for serving. This should be manually wrapped for the pages your app provides for convenience.

Gets a HashMap of the given templates by their paths for serving. This should be manually wrapped for the pages your app provides for convenience.

Checks if we’re on the server or the client. This must be run inside a reactive scope (e.g. a template! or create_effect), because it uses Sycamore context.

Structs

This encapsulates all elements of context currently provided to Perseus templates. While this can be used manually, there are macros to make this easier for each thing in here.

Represents all the different states that can be generated for a single template, allowing amalgamation logic to be run with the knowledge of what did what (rather than blindly working on a vector).

This allows the specification of all the template templates in an app and how to render them. If no rendering logic is provided at all, the template will be prerendered at build-time with no state. All closures are stored on the heap to avoid hellish lifetime specification. All properties for templates are passed around as strings to avoid type maps and other horrible things, this only adds one extra deserialization call at build time. This only actually owns a two Strings and a bool.

Type Definitions

The type of functions that amalgamate build and request states.

A type alias for a HashMap of Templates that uses Arcs for thread-safety. If you don’t need to share templates between threads, use TemplateMap instead.

The type of functions that get build paths.

The type of functions that get build state.

The type of functions that get request state.

A type alias for the function that modifies the document head. This is just a template function that will always be server-side rendered in function (it may be rendered on the client, but it will always be used to create an HTML string, rather than a reactive template).

A generic error type that can be adapted for any errors the user may want to return from a render function. .into() can be used to convert most error types into this without further hassle. Otherwise, use Box::new() on the type.

A generic error type that can be adapted for any errors the user may want to return from a render function, as with RenderFnResult<T>. However, this also includes a mandatory statement of causation for any errors, which assigns blame for them to either the client or the server. In cases where this is ambiguous, this allows returning accurate HTTP status codes.

The type of functions that modify HTTP response headers.

The type of functions that check if a template sghould revalidate.

The type of functions that are given a state and render a page. If you’ve defined state for your page, it’s safe to .unwrap() the given Option. If you’re using i18n, an Rc<Translator> will also be made available through Sycamore’s context system.

A type alias for a HashMap of Templates. This uses Rcs to make the Templates cloneable. In server-side multithreading, ArcTemplateMap should be used instead.