Skip to content

Instantly share code, notes, and snippets.

@geelen geelen/1.md
Last active Aug 29, 2015

Embed
What would you like to do?
react sweetjs early steps
macro _string {
case { _ $x } => {
var stx = #{$x};
var val = stx[0].token.value;
return [makeValue(val, #{_})];
}
}
macro foo {
rule { $x } => {
_string $x
}
}
foo bar; // -> 'bar'
macro H1 {
rule { #$id } => {
React.DOM.h1({id: $id})
}
rule { .$classes (.) ... } => {
React.DOM.h1({className: [_string $classes (,) ...].join(' ') })
}
rule {} => {
React.DOM.h1
}
}
H1();
H1.single_class_ok;
H1.one.two.three;
H1#id;
H1.'this'.'works'.'though';
H1#'this';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.