diff --git a/typed-html/src/events.rs b/typed-html/src/events.rs index 5ac38c6..49c6750 100644 --- a/typed-html/src/events.rs +++ b/typed-html/src/events.rs @@ -3,6 +3,7 @@ use crate::OutputType; use htmlescape::encode_attribute; use std::fmt::{Display, Error, Formatter}; +use std::iter; /// Trait for event handlers. pub trait EventHandler { @@ -37,6 +38,18 @@ macro_rules! declare_events_struct { )* } + impl Events { + pub fn iter(&self) -> impl Iterator { + iter::empty() + $( + .chain( + self.$name.iter() + .map(|value| (stringify!($name), value)) + ) + )* + } + } + impl Default for Events { fn default() -> Self { Events { diff --git a/typed-html/src/lib.rs b/typed-html/src/lib.rs index 8c8bfd4..0c868ee 100644 --- a/typed-html/src/lib.rs +++ b/typed-html/src/lib.rs @@ -1,3 +1,4 @@ +#![recursion_limit = "128"] //! This crate provides the `html!` macro for building HTML documents inside your //! Rust code using roughly [JSX] compatible syntax. //!