Following my encounter with yeoman, I wanted to see if I could easily create my own generators with Grunt. Not because yeoman ones were bads, they are in fact pretty good, but I just do not work exactly like Yeoman wants me too.
Another thing is that I wanted easily modifiable generators that could be used in any projects, not just with backbone.
While it’s not really hard to create that kind of functionality with Grunt once you know your way, i”m still pretty new to this and it was my first try at creating a plugin with “advanced” tasks. Still, I am happy to present my last project: grunt-bb-generate.
The idea behind this project is, yes, to provide backbone generators, but my real goal with this project is to have a base for scaffolding projects easily.
The typical command would be:
With the detault options that would generate a router (name.js) in the folder “app/scripts/routers”
Because apps do not always folder standards you can overwrite the path on the fly like this:
For more information on how to install it, please check the github repo.
Bending it to your will
Just go into the templates folder and add/change the generators to fit your style. After that go into tasks to bb_generate.js and add your new generators. There is a very easy pattern to follow, you should get the gist pretty easily.
The plugin is currently in a very rough state, I am just getting started with grunt and I really want to re-architecture the plugin a bit (contributions are welcome). I also want to add a default app structure. That’s pretty much it for now.