Struct dilla_renderer::bubbable::Bubbable
source · pub struct Bubbable {
component: Vec<String>,
pub attached_build: String,
pub library: Library,
pub style: String,
pub translation: HashMap<String, String>,
variables: HashMap<String, HashMap<String, Value>>,
}
Expand description
Support bubbable renderable with specific fields and process.
Fields§
§component: Vec<String>
§attached_build: String
Render @attached for HTML head
.
library: Library
Manage libraries defined by the component, the payload and default.
style: String
Render @variables for HTML style
.
translation: HashMap<String, String>
Collect translation to be used in templates with filter |t
.
variables: HashMap<String, HashMap<String, Value>>
Implementations§
source§impl Bubbable
impl Bubbable
pub fn new() -> Self
fn add_library_css(&mut self, css: String)
fn add_library_js(&mut self, key: String, value: Value)
sourcepub fn render_variables(&mut self)
pub fn render_variables(&mut self)
Render @variables
bubbable and attach to the ‘style’ field.
This iterates through the variables
field, which contains scoped variable
definitions. For each scope, it starts a CSS scope block. Then it iterates
through the variable definitions, checking if the variable name exists in the
global DEFINITION.variables
config. If so, it renders the variable and value
as CSS custom properties and adds them to the style
field.
The end result is that any @variables
defined in the input data are rendered
to CSS custom properties and included in the output.
sourcepub fn collect(&mut self, data: &Value)
pub fn collect(&mut self, data: &Value)
Collect bubabble properties from a serde_json::Value.
This recursively traverses the provided data
value to find and collect any
bubbable properties like components, variables, etc. It checks for specific
property keys starting with the KEY_PREFIX
and calls handler methods for
each bubbable type.
For Object
values, it iterates through each key/value pair and checks the
key before recurring or calling a handler.
For Array
values, it simply recurs on each element.
Arguments
data
- The serde_jsonValue
to collect bubbable from.