Code Monkey home page Code Monkey logo

jsx_compiler's Introduction

jsx_compiler

A procedural macro for compiling jsx into a DomElement type

Example

#![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>);

Crate Organization

jsx_macro

  • This is the main crate, which exports the jsx! and jsx_verbose! macros.

jsx_types

  • This macro exports all of the used types: HtmlToken, DomElement, EventName, Event, EventHandler, Attributes and EventHandlers.

jsx_macro_tests

  • Tests the jsx_macro crate.

TODO

  • Add RustDoc docs
  • DomElement.event_handlers is not done correctly. For example, an OnClick handlers and an OnMouseOver 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

Presentation

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).

jsx_compiler's People

Contributors

rbalicki2 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.