Expand description
Utilities for working with templates and state generation. This is by far the module you’ll probably access the most.
Macros
is_serverDeprecated
Checks if we’re on the server or the client. This must be run inside a
reactive scope (e.g. a
view!
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.
A representation of the render context of the app, constructed from
references to a series of
struct
s that mirror context values. This is
purely a proxy struct
for function organization.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.Type Definitions
The type of functions that amalgamate build and request states.
A type alias for a
HashMap
of Template
s that uses Arc
s 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 should 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 Template
s. This uses Rc
s to make the
Template
s cloneable. In server-side multithreading, ArcTemplateMap
should be used instead.