pub struct BooleanBlock;Expand description
boolean — Single checkbox; the template
renders nothing by default (host overrides decide what “true”
means in context — show a banner, flip a class, …).
Trait Implementations§
Source§impl Block for BooleanBlock
impl Block for BooleanBlock
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Wire-format identifier — the
type key in the JSON envelope
(e.g. "heading"). Must be globally unique across the process;
duplicate registrations panic at boot.Source§fn verbose_name(&self) -> &'static str
fn verbose_name(&self) -> &'static str
Human-readable label shown in the admin picker + per-block
header chip.
Source§fn icon(&self) -> Option<&'static str>
fn icon(&self) -> Option<&'static str>
Material-symbols icon name shown next to the block’s label in
the picker + the per-block header.
None → generic “widgets”
glyph.Source§fn fields(&self) -> Vec<BlockField>
fn fields(&self) -> Vec<BlockField>
Structural shape. Each entry is rendered as one form input
(or sub-stream) in the admin editor and one entry in the
block’s stored
value dict.Source§fn group(&self) -> Option<&'static str>
fn group(&self) -> Option<&'static str>
Picker grouping. Same string ⇒ same visual section in the
“+ Add block” popover.
None ⇒ “Other” bucket.Source§fn description(&self) -> Option<&'static str>
fn description(&self) -> Option<&'static str>
One-line description shown in the picker tile tooltip + the
“what does this block do” hint when the editor hovers over an
entry.
None ⇒ no tooltip.Source§fn collapsed(&self) -> bool
fn collapsed(&self) -> bool
Whether new instances of this block start collapsed in the
admin editor. Default
false (expanded). Set true for
blocks whose default value already reads well in the
collapsed header so the editor scrolls less when the page
has many of them.Source§fn default_value(&self) -> Option<Value>
fn default_value(&self) -> Option<Value>
Initial value when a fresh instance of this block is inserted
into a stream.
None ⇒ the editor opens a blank instance
(every field empty). Useful for blocks whose canonical entry
state isn’t the all-empty shape (e.g. a Heading with level=h2
pre-selected). Read moreSource§fn version(&self) -> u32
fn version(&self) -> u32
Schema version. Bump when this block’s
fields() changes in a
way that requires migrating stored JSON. Versions on disk that
differ from this trigger Self::migrate on every load.Source§fn template(&self) -> Option<&'static str>
fn template(&self) -> Option<&'static str>
Optional override of the default render template
(
blocks/<type_name>.html). Useful for blocks that share a
template with another (e.g. multiple heading-level variants).Source§fn label_format(&self) -> Option<&'static str>
fn label_format(&self) -> Option<&'static str>
Collapsed-state header template. When non-None, the admin
editor replaces the default static
Self::verbose_name
label with this string, substituting {field_name} tokens
against the current block value. Useful so a Heading block
in its collapsed state shows the actual heading text instead
of just “Heading”. Read moreSource§fn preview_value(&self) -> Option<Value>
fn preview_value(&self) -> Option<Value>
Sample value used to render a preview thumbnail inside the
block-picker tile. When set, the admin pre-renders this block
with the sample value (via
Self::preview_template or the
regular block template) and stashes the resulting HTML on
each PickerOption. Editors get a “what does this look
like” glimpse before they insert the block.Source§fn preview_template(&self) -> Option<&'static str>
fn preview_template(&self) -> Option<&'static str>
Optional override of the template used for
Self::preview_value
rendering. Defaults to Self::template (the same template
used for the public-side render). Useful when the block’s real
template emits markup that needs heavy CSS / context to look
right but a tiny mock preview is enough.Source§fn extra_context(
&self,
_value: &Value,
_ctx: &BlockRenderCtx<'_>,
) -> Map<String, Value>
fn extra_context( &self, _value: &Value, _ctx: &BlockRenderCtx<'_>, ) -> Map<String, Value>
Augments the Tera ctx
with derived values (e.g. a layout-string → grid-span map)
before the block’s template renders. Default returns an
empty map. Keys cannot shadow the framework’s own ctx
entries (
value, block_type, computed) — those are
stamped last. Read moreSource§fn render(
&self,
value: &Value,
ctx: &BlockRenderCtx<'_>,
) -> Result<String, BlockError>
fn render( &self, value: &Value, ctx: &BlockRenderCtx<'_>, ) -> Result<String, BlockError>
Render this block’s
value to HTML. The default walks
Self::fields, renders each into a Tera context map, and
renders the registered template. Override only for blocks
that bypass the field walker entirely. Read moreSource§fn migrate(&self, _from: u32, value: Value) -> Result<Value, BlockError>
fn migrate(&self, _from: u32, value: Value) -> Result<Value, BlockError>
Migrate stored JSON from an older
version() to the current
one. The registry calls this stepwise — once per integer
version between the stored value’s version and self.version()
— so authors write single-version-step migrators only. Read moreAuto Trait Implementations§
impl Freeze for BooleanBlock
impl RefUnwindSafe for BooleanBlock
impl Send for BooleanBlock
impl Sync for BooleanBlock
impl Unpin for BooleanBlock
impl UnsafeUnpin for BooleanBlock
impl UnwindSafe for BooleanBlock
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.