From 1fc165f2a5a3b6d77da2cfea2aa05e1db1c73577 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 5 Oct 2025 18:27:05 +0200 Subject: feat(form): Re-write the form macro as a proc macro This allows more possibilities. --- rocie-macros/src/form/mod.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 rocie-macros/src/form/mod.rs (limited to 'rocie-macros/src/form/mod.rs') diff --git a/rocie-macros/src/form/mod.rs b/rocie-macros/src/form/mod.rs new file mode 100644 index 0000000..2719826 --- /dev/null +++ b/rocie-macros/src/form/mod.rs @@ -0,0 +1,37 @@ +use syn::{Expr, Ident, LitStr, Type}; + +mod parse; +mod generate; + +pub use generate::form_impl; + +#[derive(Debug)] +pub struct ParsedOnSubmit { + inputs: Vec, + block: Expr, +} + +#[derive(Debug)] +pub enum ParsedChild { + Input { + name: Ident, + rust_type: Type, + html_type: LitStr, + label: LitStr, + }, + Select { + name: Ident, + label: LitStr, + rust_type: Type, + options: SelectOptions, + }, +} + +#[derive(Debug)] +pub struct SelectOptions(Vec<(LitStr, Expr)>); + +#[derive(Debug)] +pub struct ParsedInput { + on_submit: ParsedOnSubmit, + children: Vec, +} -- cgit 1.4.1