rails-generators icon indicating copy to clipboard operation
rails-generators copied to clipboard

Attempt at a submodule generator

Open jni- opened this issue 12 years ago • 3 comments

I don't think this solution is complete, but at least it eased my lazyness!

jni- avatar Apr 06 '13 06:04 jni-

Here is some doc about it too (may need reviewing, english is not my native language)


Usage :

rails generate marionette:module NAME [action action] [options]

Example : rails generate marionette:module User list show add edit

The module generator will generate a new module in backbone/apps/{module} with the {module}_app.js.coffee file inside it. For each action you will be asked if you want to generate a submodule. Saying yes will generate the following directory structure :

module/
    submodule/
        templates/
            sample.jst.eco
        submodule_controller.js.coffee
        submodule_view.js.coffee

You may also use the following options :

  • -c or --clean : Keep the generated code clean, do not generate sample view/template
  • --template-style: One of eco, ejs, hbs, hamlc, defaults to eco. Other than eco, no gem is added to your Gemfile (yet) so act accordingly.

jni- avatar Apr 06 '13 07:04 jni-

Sorry, I totally missed this comment! I just finished implementing a module generator and it's very similar to yours. I like how you've added the ability to specify the templating language.

In fact I think we should ask what templating language you're using during install, and set this as a global variable so all the generators know how to handle them.

brian-mann avatar Jul 02 '13 17:07 brian-mann

I am not that familiar with rails generator, but I guess you would have to store the preferred templating language in a file right? Or maybe you could guess from what's already there and ask again in doubt.

I'm not sure whether or not the templating language would be required by other generators though, so it probably doesn't need to be overly complex since you already separated the controller generator.

Unfortunately I won't be have time to look into this for a week or two, but i'll see what I can do after that!

Thanks

jni- avatar Jul 04 '13 02:07 jni-