Skip to content

Instantly share code, notes, and snippets.

@jagtesh
Forked from aaronpowell/gist:9085724
Last active August 29, 2015 14:22
Show Gist options
  • Save jagtesh/67e8935f11e413e3b45d to your computer and use it in GitHub Desktop.
Save jagtesh/67e8935f11e413e3b45d to your computer and use it in GitHub Desktop.
Added the ability to use multiple modules in one file
let module = macro {
case {_
$name
import $params (,) ...
} => {
letstx $name_str = [makeValue(unwrapSyntax(#{$name}), #{here})];
return #{
angular.module($name_str, [$params (,) ...])
};
}
case {_
$name
} => {
letstx $name_str = [makeValue(unwrapSyntax(#{$name}), #{here})];
return #{
angular.module($name_str)
};
}
}
let factory = macro {
case {_
$name {
import $iparams
$($mname $mparams $mbody) ...
}
} => {
letstx $name_str = [makeValue(unwrapSyntax(#{$name}), #{here})];
return #{
.factory($name_str, function $iparams {
var ret = {};
$(ret.$mname
= function $mname $mparams $mbody; ) ...
return ret;
})
};
}
}
module foo import '$a', '$b'
factory myFactory {
import ($a, $b)
say (foo) {
console.log($a);
console.log($b);
return {
a: $a[0]
};
}
}
module bar import '$x', '$y'
factory anotherFactory {
import ($http)
getFoo () {
return $http.get('http://foo');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment