Expand description
Utilities for working with templates and state generation. This is by far the module you’ll probably access the most.
Structs
- A capsule, a special type of template in Perseus that can also accept properties. Capsules are basically a very special type of Sycamore component that can integrate fully with Perseus’ state platform, generating their own states at build-time, request-time, etc. They’re then used in one or more pages, and provided extra properties.
- The equivalent of
TemplateInner
for capsules. - 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 statestruct
that stores a title and some content, which could then render as many pages as desired. - The internal representation of a Perseus template, with all the methods involved in creating and managing it. As this
struct
is notClone
, it will almost always appear wrapped in a fullTemplate
, which allows cloning and passing the template around arbitrarily. As that dereferences to this, you will be able to use any of the methods on thisstruct
onTemplate
.
Enums
- The same as
GeneratorResult
, except this uses aGenericBlamedError
as its error type, which is essentially aBox
ed generic error with an attachedErrorBlame
denoting who is responsible for the error: the client or the server. You’ll see this as a convertion type in the signatures of functions that might be run at reuqest-time (e.g.get_request_state
might have an error caused by a missing file, which would be the server’s fault, or a malformed cookie, which would be the client’s fault). - A custom
enum
representation of aResult
-style type whose error is aBox
that can accept any thread-safe error type. This is used internally as a conversion type so that your state generation functions (e.g.get_build_state
) can return either some typeT
, or aResult<T, E>
, whereE
is of your choosing. This type appears asInto<GeneratorResult<T>>
in several function signatures, and thatFrom
/Into
relation is automatically implemented for all the types you’ll need in your state generation functions.