2012年5月29日火曜日

開発中のprojectのerbファイルをhamlへ。

まず、プロジェクトルートへ移動します。
で、以下の3行をGemfileに追加。

group :development do
  gem 'erb2haml'
end

Gemfileを保存したら、
$ bundle install

install終わったら、

$ rake haml:convert_erbs

Looking for ERB files to convert to Haml...
Converting: app/views/authors/_form.html.erb... Done!
Converting: app/views/authors/edit.html.erb... Done!
Converting: app/views/authors/index.html.erb... Done!
Converting: app/views/authors/new.html.erb... Done!
Converting: app/views/authors/show.html.erb... Done!
Converting: app/views/books/_book.html.erb... SyntaxError: embedded document meets end of file. near line 3: "\r"
  Use --trace for backtrace.
Failed!
Converting: app/views/books/_form.html.erb... SyntaxError: embedded document meets end of file. near line 3: ""
  Use --trace for backtrace.
Failed!
Converting: app/views/books/edit.html.erb... Done!
<中略>
Converting: app/views/view/simple_format.html.erb... IndexError: index 74 out of string
  Use --trace for backtrace.
Failed!
Converting: app/views/view/truncate.html.erb... Done!

いくつか失敗してるけど、フォーマットの問題と踏んで、気にせず次に行こう。
気になる人は、ちゃんと--traceオプションつけたり、もとのerbファイルを見直しましょう。
#変換失敗した場合は、hamlファイルは生成されてるけど、中身が空です。

それと、erbは残っているみたいなので、不要なら消してね☆
ちなみに、2回目の変換の場合は、差分のみ出力されました。

0 件のコメント:

コメントを投稿