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

is_serverDeprecated

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

The properties that every page will be initialized with. You shouldn’t ever need to interact with this unless you decide not to use the template macros.

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.

The state for the router.

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.

Enums

The current load state of the router. You can use this to be warned of when a new page is about to be loaded (and display a loading bar or the like, perhaps).

Functions

Creates the default headers used in Perseus. This is the default value for set_headers on every Template<G>

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 inside PageProps. 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.