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: AriaAttributesARIA attributes for accessibility.
children: ChildrenSpecChild 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
impl RenderOutput
Sourcepub fn with_attr(self, name: impl Into<String>, value: AttrValue) -> Self
pub fn with_attr(self, name: impl Into<String>, value: AttrValue) -> Self
Add an HTML attribute.
Sourcepub fn with_class(self, class: impl Into<String>) -> Self
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.
Sourcepub fn with_classes(
self,
classes: impl IntoIterator<Item = impl Into<String>>,
) -> Self
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.
Sourcepub fn with_aria(self, aria: AriaAttributes) -> Self
pub fn with_aria(self, aria: AriaAttributes) -> Self
Set the ARIA attributes.
Sourcepub fn with_children(self, children: ChildrenSpec) -> Self
pub fn with_children(self, children: ChildrenSpec) -> Self
Set the children specification.
Sourcepub fn with_data(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_data( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Add a data attribute.
Sourcepub fn with_style(
self,
property: impl Into<String>,
value: impl Into<String>,
) -> Self
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.
Sourcepub fn effective_tag(&self) -> &str
pub fn effective_tag(&self) -> &str
Get the effective tag name (defaults to “div”).
Sourcepub fn class_string(&self) -> String
pub fn class_string(&self) -> String
Get all classes as a single space-separated string.
Sourcepub fn style_string(&self) -> String
pub fn style_string(&self) -> String
Get all inline styles as a CSS string.
Sourcepub fn merge(self, other: RenderOutput) -> Self
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
impl Clone for RenderOutput
Source§fn clone(&self) -> RenderOutput
fn clone(&self) -> RenderOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more