Skip to main content

RenderOutput

Struct RenderOutput 

Source
pub struct RenderOutput {
    pub attrs: Vec<(String, AttrValue)>,
    pub classes: Vec<String>,
    pub aria: AriaAttributes,
    pub children: ChildrenSpec,
    pub data_attrs: Vec<(String, String)>,
    pub tag: Option<String>,
    pub styles: Vec<(String, String)>,
}
Expand description

Framework-agnostic render description produced by components.

A RenderOutput describes what a component looks like without committing to any specific framework’s rendering model. Framework adapters translate this into Leptos view! or Dioxus rsx! output.

Fields§

§attrs: Vec<(String, AttrValue)>

HTML attributes to set on the root element.

§classes: Vec<String>

CSS class names to add to the root element.

§aria: AriaAttributes

ARIA attributes for accessibility.

§children: ChildrenSpec

Child content specification.

§data_attrs: Vec<(String, String)>

Data attributes (data-*) for testing and JS interop.

§tag: Option<String>

The HTML tag name to render (default: “div”).

§styles: Vec<(String, String)>

Inline styles (escape hatch — prefer classes).

Implementations§

Source§

impl RenderOutput

Source

pub fn new() -> Self

Create a new empty RenderOutput.

Source

pub fn with_tag(self, tag: impl Into<String>) -> Self

Set the HTML tag name.

Source

pub fn with_attr(self, name: impl Into<String>, value: AttrValue) -> Self

Add an HTML attribute.

Source

pub fn with_class(self, class: impl Into<String>) -> Self

Add a CSS class.

Validates the class name to prevent CSS injection. Invalid class names are silently dropped. Use crate::security::is_safe_class_name to check before calling if you need to handle the error.

Source

pub fn with_classes( self, classes: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Add multiple CSS classes.

Each class is validated individually via crate::security::is_safe_class_name. Invalid class names are silently dropped.

Source

pub fn with_aria(self, aria: AriaAttributes) -> Self

Set the ARIA attributes.

Source

pub fn with_children(self, children: ChildrenSpec) -> Self

Set the children specification.

Source

pub fn with_data( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Add a data attribute.

Source

pub fn with_style( self, property: impl Into<String>, value: impl Into<String>, ) -> Self

Add an inline style.

Validates the value to prevent CSS injection. Unsafe values (containing expression(), url(), javascript:, etc.) are silently dropped.

Source

pub fn effective_tag(&self) -> &str

Get the effective tag name (defaults to “div”).

Source

pub fn class_string(&self) -> String

Get all classes as a single space-separated string.

Source

pub fn style_string(&self) -> String

Get all inline styles as a CSS string.

Source

pub fn merge(self, other: RenderOutput) -> Self

Merge another RenderOutput into this one.

Attributes, classes, data attributes, and styles are appended. ARIA attributes from other overwrite self where set. Tag and children from other take precedence if set.

Trait Implementations§

Source§

impl Clone for RenderOutput

Source§

fn clone(&self) -> RenderOutput

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RenderOutput

Source§

fn default() -> RenderOutput

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RenderOutput

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RenderOutput

Source§

fn eq(&self, other: &RenderOutput) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for RenderOutput

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RenderOutput

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Props for T
where T: Clone + PartialEq + 'static,

Source§

impl<T> State for T
where T: Clone + 'static,