Skip to main content

serenade_view/
lib.rs

1//! HTML view helpers: reverse routing, assets, partials, and document composition.
2//!
3//! Escape stays in [`serenade_form`]; this crate re-exports it for one import surface.
4//! Document composition is engine-neutral; template engines can integrate without
5//! becoming mandatory dependencies of this crate. The optional `leptos-ssr` feature
6//! renders complete documents under a request-scoped Leptos owner and injects managed
7//! metadata. The `leptos-client` feature exposes the head root and lifecycle components
8//! used by CSR/hydrated apps. Compatible AOT compilers can target these components
9//! without becoming dependencies of this crate.
10
11mod asset;
12mod document;
13mod error;
14#[cfg(any(feature = "leptos-client", feature = "leptos-ssr"))]
15mod head;
16mod partial;
17mod path;
18#[cfg(not(target_arch = "wasm32"))]
19mod static_output;
20mod trunk_assets;
21
22#[cfg(feature = "leptos-ssr")]
23pub use any_spawner::Executor as LeptosExecutor;
24pub use asset::{AssetConfig, asset};
25pub use document::{
26    DefaultDocumentTemplate, Document, DocumentAssets, DocumentParts, DocumentTemplate,
27    RenderedDocument,
28};
29#[cfg(feature = "leptos-ssr")]
30pub use document::{DocumentSlot, initialize_leptos_ssr};
31pub use error::ViewError;
32#[cfg(any(feature = "leptos-client", feature = "leptos-ssr"))]
33pub use head::{JsonLd, ManagedHead, ManagedLink, ManagedMeta, ManagedTitle};
34pub use partial::partial;
35pub use path::path;
36pub use serenade_form::{escape_attr, escape_html};
37#[cfg(not(target_arch = "wasm32"))]
38pub use static_output::{STATIC_OUTPUT_DIR_ENV, StaticDocumentWriter};
39pub use trunk_assets::{
40    TRUNK_ASSET_MANIFEST_ENV, TRUNK_ASSET_MANIFEST_FILE, TRUNK_DIST_DIRECTORY_ENV,
41    TrunkAssetManifest, TrunkAssetReference, TrunkDocumentAsset, TrunkPreloadReference,
42    TrunkWasmBundle,
43};
44
45/// Compile-time crate version for diagnostics.
46#[must_use]
47pub const fn version() -> &'static str {
48    env!("CARGO_PKG_VERSION")
49}
50
51#[cfg(test)]
52mod tests;