2012年5月29日火曜日

hamlを使う。

先日から、hamlジェネレータで遊んでいましたが、rails上でサンプルを動かしてみた。

$ rails new hamltest
$ cd hamltest
$ bundle install vendor/bundle

としたら、3行目の書き方は、deprecatedだってさ。
なので、言われた通りにしてみる。

$ bundle install --path vendor/bundle
...
Your bundle is complete! It was installed into ./vendor/bundle

うん、上出来。

で、Gemfile開いて、以下の1行を追加。
gem 'haml-rails'

で、
$ bundle install

からの
$ rails g controller sample index

って打ってみると、


create  app/controllers/sample_controller.rb
       route  get "sample/index"
      invoke  haml
      create    app/views/sample
      create    app/views/sample/index.html.haml
      invoke  test_unit
      create    test/functional/sample_controller_test.rb
      invoke  helper
      create    app/helpers/sample_helper.rb
      invoke    test_unit
      create      test/unit/helpers/sample_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/sample.js.coffee
      invoke    scss
      create      app/assets/stylesheets/sample.css.scss



よしよし、erb -> hamlへと変わっている。
これで、localhost:3000たたいて動けばOK。

また、よくよく見ると、CoffeeScriptまでできるようになっているではないか!
これは、後ほど勉強しますか。

そういや、環境書いてなかったね。
------------------
MacOS Lion
ruby 1.9.2
Rails 3.2.3
------------------

0 件のコメント:

コメントを投稿