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 w开发者_Go百科ouldn't work.
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.
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.
app/views/layouts/application.html.haml
!!!
%html
%head
%title "HAML'd"
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= csrf_meta_tags
%body
= yield
Make sure you have the haml-rails
gem installed.
Don't forget to add gem 'haml-rails'
to your Gemfile.
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.
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/
精彩评论