chrismccord / phoenix_haml

Phoenix Template Engine for Haml
MIT License
158 stars 42 forks source link

Added generator: $ mix phoenix_haml.gen.html #32

Closed parndt closed 8 years ago

parndt commented 8 years ago

This works in the same manner as $ mix phoenix.gen.html but will produce HAML templates in place of the default eex ones.

Example:

$ mix phoenix_haml.gen.html MyHamlThing my_haml_things name:string
* creating web/controllers/my_haml_thing_controller.ex
* creating test/controllers/my_haml_thing_controller_test.exs
* creating web/views/my_haml_thing_view.ex
* creating web/templates/my_haml_thing/edit.html.haml
* creating web/templates/my_haml_thing/form.html.haml
* creating web/templates/my_haml_thing/index.html.haml
* creating web/templates/my_haml_thing/new.html.haml
* creating web/templates/my_haml_thing/show.html.haml
* creating web/models/my_haml_thing.ex
* creating test/models/my_haml_thing_test.exs
* creating priv/repo/migrations/20160226220620_create_my_haml_thing.exs

Add the resource to your browser scope in web/router.ex:

    resources "/my_haml_things", MyHamlThingController

Remember to update your repository by running migrations:

    $ mix ecto.migrate

This replaces phoenixframework/phoenix#1568

It would be good if the generator from phoenix has defoverridable or __using__ so that all of this code doesn't have to be copy pasted for every different template language that needs a generator, but currently that's the way it is.

The team at Manuka Coalition (@manukaco) are happy to maintain this generator.

chrismccord commented 8 years ago

The task should be phoenix_haml.gen.html

parndt commented 8 years ago

@chrismccord it has been so renamed

parndt commented 8 years ago

Any chance we can enable Travis CI for this repo? https://travis-ci.org/chrismccord/phoenix_haml :heart:

parndt commented 8 years ago

@chrismccord anything else that you'd like done to this PR?

smpallen99 commented 8 years ago

I wrote a haml generator, and it looks very similar to this one. I've reviewed the code and only have one comment. In the index template, you should use - for ..., instead of = for ..... Calliope was designed to use -. Other than that, I would like to see this pull request merged.

Steve

parndt commented 8 years ago

@smpallen99 great feedback, that does work!