How to run a Rails 3 application with HAML and SASS as default templates?

line

rails new someapp -m haml 

does not work. It seems to need a path to something where.

Update: haml-rails actually installed gem install haml-rails , but the line above will not work.

+4
source share
7 answers

Very short version

Create a new rails application based on a simple template that installs Haml out of the box (and some other interesting additional features).

 rails new ProjectName -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb 

http://decielo.com/articles/377/haml-by-default-in-a-new-rails-3-2-app

Also check this out:

https://github.com/RailsApps/rails-composer

EDIT:

If you want to do this through the gem, you just need to run the default command

rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

This is a safe command because it points to the main branch of the gem and will be a stable URL. After running this command, you will be offered options. Just ask the HAML and SASS masters.

+9
source

Gem haml-rails allows you to generate views in Haml, but not the original layout.

After running rails new someapp (note: w / o -m haml ) and adding the gem "haml-rails" to your Gemfile you just need to rename application.html.erb to application.html.haml and manually convert its contents from ERB to Haml.

After that, all generated views will be in Haml.

+5
source

application / views / layouts / application.html.haml

 !!! %html %head %title "HAML'd" = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tags %body = yield 
+5
source

Make sure haml-rails stone is installed.

+1
source

Remember to add the gem 'haml-rails' to your gemfile.

0
source

It is trivial, but make sure you restart the rail server after adding haml gems and run bundle install . This led me for the first time.

0
source

Install gem html2haml and you can instantly change html content for haml from within vim. Take a look at this - http://www.economyofeffort.com/2014/07/20/convert-html-to-haml-within-vim-buffer/

0
source

All Articles