pub struct HtmlShell {
pub shell: String,
pub head_before_boundary: Vec<String>,
pub scripts_before_boundary: Vec<String>,
pub head_after_boundary: Vec<String>,
pub scripts_after_boundary: Vec<String>,
pub content: String,
pub before_content: Vec<String>,
pub after_content: Vec<String>,
/* private fields */
}
Expand description
The shell used to interpolate the Perseus app into, including associated scripts and content defined by the user, components of the Perseus core, and plugins.
Fields
shell: String
The actual shell content, on whcih interpolations will be performed.
head_before_boundary: Vec<String>
Additional contents of the head before the interpolation boundary.
scripts_before_boundary: Vec<String>
Scripts to be inserted before the interpolation boundary.
head_after_boundary: Vec<String>
Additional contents of the head after the interpolation boundary. These will be wiped out after a page transition.
scripts_after_boundary: Vec<String>
Scripts to be interpolated after the interpolation bounary. These will be wiped out after a page transition.
content: String
Content to be interpolated into the body of the shell.
before_content: Vec<String>
Code to be inserted into the shell before the Perseus contents of the page. This is designed to be modified by plugins.
after_content: Vec<String>
Code to be inserted into the shell after the Perseus contents of the page. This is designed to be modified by plugins.
Implementations
sourceimpl HtmlShell
impl HtmlShell
sourcepub fn new(
shell: String,
root_id: &str,
render_cfg: &HashMap<String, String>,
path_prefix: &str
) -> Self
pub fn new(
shell: String,
root_id: &str,
render_cfg: &HashMap<String, String>,
path_prefix: &str
) -> Self
Initializes the HTML shell by interpolating necessary scripts into it and adding the render configuration.
sourcepub fn page_data(
self,
page_data: &PageData,
global_state: &Option<String>
) -> Self
pub fn page_data(
self,
page_data: &PageData,
global_state: &Option<String>
) -> Self
Interpolates page data and global state into the shell.
sourcepub fn locale_redirection_fallback(self, redirect_url: &str) -> Self
pub fn locale_redirection_fallback(self, redirect_url: &str) -> Self
Interpolates a fallback for locale redirection pages such that, even if JavaScript is disabled, the user will still be redirected to the default locale. From there, Perseus’ inbuilt progressive enhancement can occur, but without this a user directed to an unlocalized page with JS disabled would see a blank screen, which is terrible UX. Note that this also includes a fallback for if JS is enabled but Wasm is disabled. Note that the redirect URL is expected to be generated with a path prefix inbuilt.
This also adds a __perseus_initial_state
<div>
in case it’s needed (for Wasm redirections).
Further, this will preload the Wasm binary, making redirection snappier (but initial load slower), a tradeoff that generally improves UX.
sourcepub fn error_page(
self,
error_page_data: &ErrorPageData,
error_html: &str
) -> Self
pub fn error_page(
self,
error_page_data: &ErrorPageData,
error_html: &str
) -> Self
Interpolates page error data into the shell in the event of a failure.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for HtmlShell
impl Send for HtmlShell
impl Sync for HtmlShell
impl Unpin for HtmlShell
impl UnwindSafe for HtmlShell
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, G> IntoView<G> for T where
T: 'static + Display,
G: GenericNode,
impl<T, G> IntoView<G> for T where
T: 'static + Display,
G: GenericNode,
sourcefn create(&self) -> View<G>
fn create(&self) -> View<G>
Called during the initial render when creating the DOM nodes. Should return a
Vec
of GenericNode
s. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more