workers-rsx 0.1.0

A JSX-like templating engine for Cloudflare Workers
Documentation
pub mod fragment;
pub mod fragments;
pub mod html;
pub mod html_escaping;
mod numbers;
mod render;
pub mod simple_element;
pub mod state;
mod text_element;
mod dispatch;

pub use dispatch::{dispatch, handle, Reducer};
pub use self::render::Render;

// Re-export for use by derive macros
#[doc(hidden)]
pub use serde_json;
pub use fragment::Fragment;
pub use fragments::diff_html;
pub use simple_element::SimpleElement;
pub use state::decode_state;
pub use text_element::Raw;
pub use text_element::RawOwned;
pub use workers_rsx_impl::{component, css, html, page, rsx, view};
pub use workers_rsx_impl::ActionJson;

/// Tailwind CSS v4 preflight (base reset styles), minified.
/// See: https://tailwindcss.com/docs/preflight
pub static PREFLIGHT_CSS: &str = include_str!("preflight.css");

/// Generate Tailwind CSS from a list of class names using `tailwind-rs-core`.
/// Returns an empty string if no classes produce valid CSS.
pub fn generate_tailwind_css(class_names: &[&str]) -> String {
    let mut generator = tailwind_rs_core::CssGenerator::new();
    for name in class_names {
        let _ = generator.add_class(name);
    }
    let utility_css = generator.generate_css();
    if utility_css.is_empty() {
        return String::new();
    }
    format!("{}{}", PREFLIGHT_CSS, utility_css)
}

/// Create a raw (unencoded) HTML string
#[macro_export]
macro_rules! raw {
    ($s:expr) => {
        ::workers_rsx::Raw::from($s)
    };
}