nonopolarity
nonopolarity

Reputation: 150976

How to start a Rails 3 app with HAML and SASS as the default templates?

the line

rails new someapp -m haml

doesn't work. It seems to need a path to some where.

Update: haml-rails is in fact installed by gem install haml-rails but the line above wouldn't work.

Upvotes: 5

Views: 10044

Answers (7)

Ketan Shukla
Ketan Shukla

Reputation: 1

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

Upvotes: 0

Abram
Abram

Reputation: 41844

The really short version

Generate a new rails app based on a simple template that sets up Haml out of the box (and some other nice optional 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 simply 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 as it points to the master branch of the gem and will be a stable URL. Once you have run this command you will be prompted with options. Simply select HAML and SASS when asked by the wizard.

Upvotes: 9

Excalibur
Excalibur

Reputation: 3367

Trivial, but make sure you restart your rails server after adding the haml gems and run bundle install. This got me the first time around.

Upvotes: 0

nil0bject
nil0bject

Reputation: 59

app/views/layouts/application.html.haml

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

Upvotes: 5

Andy
Andy

Reputation: 10988

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

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

After that, all generated views will be in Haml.

Upvotes: 5

Justin Workman
Justin Workman

Reputation: 698

Don't forget to add gem 'haml-rails' to your Gemfile.

Upvotes: 0

Natalie Weizenbaum
Natalie Weizenbaum

Reputation: 5964

Make sure you have the haml-rails gem installed.

Upvotes: 1

Related Questions