| Crates.io | maud-extensions |
| lib.rs | maud-extensions |
| version | 0.1.2 |
| created_at | 2026-01-06 15:54:56.067299+00 |
| updated_at | 2026-01-06 16:13:05.468114+00 |
| description | Inline CSS, JS, and font helper macros for Maud views. |
| homepage | https://github.com/eboody/maud-extensions |
| repository | https://github.com/eboody/maud-extensions |
| max_upload_size | |
| id | 2026141 |
| size | 56,391 |
Proc macros to simplify Maud views with inline CSS, JS, and font helpers.
cargo add maud-extensions
use maud_extensions::{css, js};
maud::html! {
div class="card" {
(css! {
me { padding: 8px; border: 1px solid #ddd; }
me em { color: #c00; }
})
p { "Inline CSS and JS" }
(js! {
me().class_add("ready");
})
}
}
css! { ... } or css!("...")
<style> block with raw CSS.cssparser.js! { ... } or js!("...")
<script> block with raw JS.swc_ecma_parser.inline_css! { ... } and inline_js! { ... }
fn css() -> maud::Markup / fn js() -> maud::Markup helpers.font_face! and font_faces!
These macros are often paired with a tiny JS scoper like
css-scope-inline. It rewrites
selectors like me { ... } to a unique class on the parent element.
Example:
(css! {
me { border: 1px dashed var(--accent); }
me em { font-style: normal; }
})
The JS macro is format-preserving but may add spacing for token safety. It
still emits valid JavaScript. The examples use
surreal for the me() helper, but any
inline script works.
(js! {
me().class_add("pinged");
})
font_face! and font_faces! embed font files as base64 data URLs. Because
this macro expands at the call site, the consuming crate must include base64
if you use these macros.
use maud_extensions::font_face;
maud::html! {
(font_face!("static/fonts/JetBrainsMono.woff2", "JetBrains Mono"))
}
MIT OR Apache-2.0