A small library for generating a tree of objects representing routes, as well as file paths.
Can be used to reduce a lot of require boilerplate when you create and app with a consistent route -> directory mapping. Provides some options for times when the structure isn't so well mapped :).
Needs something like Webpack that can handle dynamic requires.
Todo
- Document it a bit better
- Add tests
- Possibly remove
routes
just useroute
Example
With react-router and webpack:
var React = ;var Route DefaultRoute = ;var route routes = ; moduleexports = ; { propschildren = propschildren ? propschildren : null; propshandler = ; return propsdefaultRoute ? <DefaultRoute /> : <Route />;}
Corresponing file tree, notice how dir
affects nesting:
/components /kitchen Controls.jsx Modals.jsx Popovers.jsx Kitchen.jsx App.jsx