A procedural macro for compiling jsx into a
DomElement
type
#![feature(proc_macro, proc_macro_non_items)]
extern crate jsx_types;
extern crate jsx_macro;
let on_click: Box<jsx_types::EventHandler> = Box::new(|_| println!("foo!"));
let subtitle = "This is a subtitle";
let dom = jsx!(<div foo="bar">
<h1 OnClick={on_click}>This title is clickable</h1>
<div class="subtitle">{ subtitle }</div>
</div>);
- This is the main crate, which exports the jsx! and jsx_verbose! macros.
- This macro exports all of the used types:
HtmlToken
,DomElement
,EventName
,Event
,EventHandler
,Attributes
andEventHandlers
.
- Tests the
jsx_macro
crate.
- Add RustDoc docs
DomElement.event_handlers
is not done correctly. For example, anOnClick
handlers and anOnMouseOver
handlers should receive different events. Thus,DomElement
should have separate, optional fields, e.g.:
pub type DomElement {
// ... other fields
on_click: Option<Box<FnOnce(ClickEvent) -> ()>>,
on_mouseover: Option<Box<FnOnce(MouseEvent) -> ()>>,
}
- There should be also be a builder-pattern constructor for
DomElement
. - Integrate with a wasm full-stack app.
- Other methods:
to_inner_html
and the like. - Spacing on multiline idents and such
Follow along with the presentation and with the video. The code that is current at the time of the presentation was tag v7, but you should have no trouble following along with master (as of July 8th).