pub trait DocumentTemplate<Head, Body> {
// Required method
fn render(
self,
parts: DocumentParts<Head, Body>,
) -> Result<String, ViewError>;
}Expand description
A template engine’s document-level composition boundary.
Implementations own the document structure, language, and head/body slots. They consume the head and body inputs and return one complete HTML document.
The application head template owns title, metadata, canonical links, JSON-LD, and custom head markup; the body template/component owns page content. Shared head entries come from the document template. Route-owned entries replace shared singleton entries only when they declare the same stable key, leaving unrelated shared entries intact. Repeatable entries use distinct keys and are retained. Keys are declared by templates/integrations, never recovered by parsing rendered HTML.
Rust controllers remain responsible for data and orchestration, not markup.
Template-engine and AOT adapters can implement this contract as optional
integrations; the engine-neutral serenade-view helpers do not require them.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<Head, Body, HeadView, BodyView, Template, View> DocumentTemplate<Head, Body> for Template
leptos-ssr only.impl<Head, Body, HeadView, BodyView> DocumentTemplate<Head, Body> for DefaultDocumentTemplate
leptos-ssr only.