april-ui-rust 0.1.0

April UI components for Laravel Rust and MiniJinja
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use laravel::view::minijinja::{Error, State, Value};

/// Keep Laravel's attribute bag and escaping, resolving only April's Tailwind classes.
pub(crate) fn merge(state: &State<'_, '_>, attributes: Value) -> Result<Value, Error> {
    let class = attributes.call_method(state, "get", &[Value::from("class")])?;
    let Some(class) = class.as_str() else {
        return Ok(attributes);
    };
    let class = tw_merge::merge::tw_merge_slice(&[class]);
    let without_class = attributes.call_method(state, "except", &[Value::from("class")])?;
    without_class.call_method(state, "merge", &[Value::from_iter([("class", class)])])
}