Expand description
Macros for use with the Leptos framework.
Macros§
- include_
view - This behaves like the
view
macro, but loads the view from an external file instead of parsing it inline. - memo
- Generates a
memo
into a struct with a default getter. - slice
- Generates a
slice
into a struct with a default getter and setter. - template
- The
template
macro behaves likeview
, except that it wraps the entire tree in aViewTemplate
. This optimizes creation speed by rendering most of the view into a<template>
tag with HTML rendered at compile time, then hydrating it. In exchange, there is a small binary size overhead. - view
- The
view
macro uses RSX (like JSX, but Rust!) It follows most of the same rules as HTML, with the following differences:
Attribute Macros§
- component
- Annotates a function so that it can be used with your template as a Leptos
<Component/>
. - island
- Defines a component as an interactive island when you are using the
islands
feature of Leptos. Apart from the macro name, the API is the same as thecomponent
macro. - lazy
- The
#[lazy]
macro marks anasync
function as a function that can be lazy-loaded from a separate (WebAssembly) binary. - server
- Declares that a function is a server function.
This means that its body will only run on the server, i.e., when the
ssr
feature on this crate is enabled. - slot
- Annotates a struct so that it can be used with your Component as a
slot
.
Derive Macros§
- Params
- Derives a trait that parses a map of string keys and values into a typed data structure, e.g., for route params.