Devise generators use erb instead of haml - ruby-on-rails-3

I'm trying to generate haml views with devise, but it always use erb instead. I'm running rails 3.1 & ruby 1.9.2. Rails generators (like scaffold) generates haml. I tried setting the template engine :
config.generators do |g|
g.template_engine :haml
end
But still doesn't work. If you have an idea, it is most welcomed.
Thanks for your time !

It's not possible to generate them out of the box. However, there is a short tutorial on how to convert the erb views from devise to haml layout using html2haml and a simple bash script.

That means that Devise doesn't have templates for HAML. However like #halfdan said it's pretty easy to convert with html2haml...

Related

pycharm code completion / syntax highlighting for django in haml files

I just tried to use HAML in my django project, which works fine^^
But while writing beautiful HAML code PyCharm refuse to offer any code completion or syntax highlighting for django template tags like in HTML files.
Do I need to configure PyCharm differently or is it just not possible to get the "Django Support" in HAML files with PyCharm?
Thanks in advance
I've found an older issue related to this one.
"At the moment the HAML support is part of the RubyMine code and can't be
used in other products. We have an issue for making it independent:
http://youtrack.jetbrains.net/issue/RUBY-6432"
Not sure if they managed to extract the HAML support to PyCharm or not. Their tracker is overloaded so I couldn't check it.

Including/importing HAML files using grunt-contrib-haml and Yeoman

I am currently using Yeoman with HAML (utilising grunt-contrib-haml) and would like to include HAML files to make things more DRY.
I am not that familiar with HAML, so after reading online it appears best to use =render, like so:
=render(partial="shared/ga")
however I am receiving the message that HAML lacks a native render() function:
Warning: Exception on line 75: undefined method `render' for #<Object:0x00000003474a98>
Is there a simple way to include HAML files from inside another HAML file, which will work with Yeoman/grunt-contrib-haml? and/or extending an existing HAML template to make things more DRY?
I had the same issue. I found that the simplest approach to this issue is to use js to import the files instead of the haml method. I'm using Angular.js so I can use it's imports and skip HAML's.
In the HAML template you write something like this (for Angular):
%div#publish{ng-include: 'views.someview', ng-controller: 'SomeCtrl'}
Works like a charm.

HAML markdown rendering and showing ERB within

I have this in one of my HAML templates:
:markdown
#{render 'home.md'}
and in home.md I have:
There are **#{#photo_count}** photos.
When viewing the site, it literally outputs that. How can I get the #photo_count variable to be interpolated?
For a pure Markdown file, I don't think you'll be able to do what you want as the format itself won't support your Ruby variable.
If you don't mind changing your markdown file to a HAML partial file (no need to change its content), you could do something like this (I've used something similar to the code below using the RDiscount gem; your mileage may vary with other Markdown gems...):
app/controllers/pages_controller.rb
def home
#photo_count = 10
end
app/views/pages/home.html.haml
:markdown
#{render 'home_page'}
app/views/pages/_home_page.html.haml
There are **#{#photo_count}** photos.
See also this StackOverflow Q&A for other ideas:
How can I automatically render partials using markdown in Rails 3?

In Rails 3, using Formtastic 2, how can I replace the built in ordered list with div's?

In my Rails 3 application I'm using Twitter Bootstrap as a frame work for developing an in house project management system. I'm using Formtastic to help me with forms since it save a lot of time and code. My problem is getting the Formtastic code to output the forms in a way that correspond with Bootstrap's conventions. I've read a few items I found on Google suggesting that I should monkey patch Formtastic, but I haven't been able to do this successfully.
How can I customize Formtastic's output to use div's around each field so I can use Bootstrap with it?
Thank you for looking.
Well, today I tried forking formtastic and making it compatible with bootstrap... The markup is incredibly tightly coupled to the code, so I gave up and switched to simple_form instead. Works fine with the advice in Rails: Using simple_form and integrating Twitter Bootstrap
You can use the formtastic-bootstrap gem. You should be able to drop this in and it will generate HTML that will work naturally with Twitter Bootstrap.
If you use the SCSS files from the one of the scss-twitter-bootstrap projects, you can simply comment out or remove the include for the forms part of the CSS.
Simply copy them in to app/stylesheets (Rails 3.0) or app/assets/stylesheets and comment out:
// #import "forms.scss";
Don't forget to add the formtastic CSS back in:
<%= stylesheet_link_tag 'formtastic', 'formtastic_changes' %>

How to override inherited_resources with the rails scaffold command

I am using the active_admin gem in my Rails 3 application, which has as a dependency inherited_resources. I am somewhat of a newb and would rather avoid the black box qualities of inherited_resources for my own controllers, however, when I run the default rails g scaffold command, the controllers that are generated are inheriting from inherited_resources. I know that I can manually override this by inheriting from ApplicationController, however, I would like to be able to generate the default rails scaffolds if possible.
-c=scaffold_controller
or add this to config/application.rb
config.generators do |g|
g.scaffold_controller "scaffold_controller"
end
Also noted in an issue thread over at github: https://github.com/josevalim/inherited_resources/issues/195