pub struct TabSpec {
pub name: String,
pub label: String,
pub icon: Option<String>,
pub badge: Option<String>,
pub body: TabBody,
}Expand description
One handler-contributed tab appended to the page-editor’s
built-in tab strip (Content / Promote / Theme / Revisions). See
PageTypeHandler::extra_tabs.
The body is one of TabBody::Html (pre-rendered HTML — the
escape hatch), TabBody::Template (Tera template path + extra
context — render with the standard admin context vars in scope),
or TabBody::Widgets (declarative widget list — rendered via
_widget.html so the form fields look identical to the Content
tab’s stack).
Inputs declared inside the rendered HTML land in
PageTypeHandler::save_extension’s form HashMap automatically;
every variant lives inside the page-edit <form>.
name must be unique within a page’s tab set. Mixing with the
built-in names (content, promote, theme, revisions) is
allowed and lets a handler override the BUILT-IN tab body without
forking the template; the tab JS keys off data-tab-trigger="<name>"
so identical names render the same panel.
Fields§
§name: StringStable identifier — kebab-case is conventional. Used for
aria-controls, URL hash links, and the per-page localStorage
“remember last active tab” key.
label: StringVisible label on the tab button.
icon: Option<String>Optional Material-symbols icon name (e.g. "workflow",
"insights"). Rendered to the left of label.
badge: Option<String>Optional small chip rendered after label (e.g. an unread
count, “new”, or a small status indicator).
body: TabBodyWhat goes inside the tab panel — see TabBody.
Implementations§
Source§impl TabSpec
impl TabSpec
Sourcepub fn new(
name: impl Into<String>,
label: impl Into<String>,
html: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, label: impl Into<String>, html: impl Into<String>, ) -> Self
Smallest possible spec — just (name, label, html). The
html is treated as pre-rendered + emitted via Tera’s
| safe. Backwards-compatible with the v0.2 surface.
Sourcepub fn template(
name: impl Into<String>,
label: impl Into<String>,
path: impl Into<String>,
) -> Self
pub fn template( name: impl Into<String>, label: impl Into<String>, path: impl Into<String>, ) -> Self
Tera-template-backed tab. The renderer mounts path with the
standard admin context plus the per-tab context map (empty
until filled with Self::with_context_value). Example:
TabSpec::template("seo", "SEO", "blog/seo_tab.html").
Sourcepub fn widgets(
name: impl Into<String>,
label: impl Into<String>,
widgets: Vec<Widget>,
) -> Self
pub fn widgets( name: impl Into<String>, label: impl Into<String>, widgets: Vec<Widget>, ) -> Self
Widget-group-backed tab. Same rendering pipeline the Content
tab uses — each widget is emitted via _widget.html’s macro.
Inputs submit alongside the page-edit form so the handler’s
PageTypeHandler::save_extension picks them up by name.
Sourcepub fn group(
name: impl Into<String>,
label: impl Into<String>,
heading: impl Into<String>,
widgets: Vec<Widget>,
) -> Self
pub fn group( name: impl Into<String>, label: impl Into<String>, heading: impl Into<String>, widgets: Vec<Widget>, ) -> Self
Field-group tab — heading + (optional help) +
widgets stacked under one section. Use Self::with_layout
to switch to row layout.
Sourcepub fn help(
name: impl Into<String>,
label: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn help( name: impl Into<String>, label: impl Into<String>, content: impl Into<String>, ) -> Self
Help tab — static HTML content, no form fields.
The body is emitted via | safe, so authors control the markup.
Sourcepub fn with_layout(self, layout: PanelLayout) -> Self
pub fn with_layout(self, layout: PanelLayout) -> Self
Switch a Group-body tab to a different layout. No-op on other body variants.
Sourcepub fn with_help(self, help: impl Into<String>) -> Self
pub fn with_help(self, help: impl Into<String>) -> Self
Attach help text to a Group-body tab. No-op on other body variants.
pub fn with_icon(self, icon: impl Into<String>) -> Self
pub fn with_badge(self, badge: impl Into<String>) -> Self
Sourcepub fn with_context_value(self, key: impl Into<String>, value: Value) -> Self
pub fn with_context_value(self, key: impl Into<String>, value: Value) -> Self
Insert a context entry — only meaningful for the
TabBody::Template variant; a no-op on Html / Widgets.
Chain multiple times for multiple values.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TabSpec
impl<'de> Deserialize<'de> for TabSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Forget for TabSpec
impl Freeze for TabSpec
impl RefUnwindSafe for TabSpec
impl Send for TabSpec
impl Sync for TabSpec
impl Unpin for TabSpec
impl UnsafeUnpin for TabSpec
impl UnwindSafe for TabSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more