Ruby-mineはhamlの補完機能とかあって、快適です。
何故かテンプレートが用意されていないのは気持ち悪いけど。。
とりあえず、設定としてはこんな感じで今のところはストレスレス
ドキュメント
- 手っ取り早し参照先
- 詳細なドキュメント
迷ったところ
indentってスペース?タブ?
Indentation
Haml's indentation can be made up of one or more tabs or spaces. However,
indentation must be consistent within a given document.
Hard tabs and spaces can't be mixed, and the same number
of tabs or spaces must be used throughout.
インデントはハードタブでもソフトタブ(space)でもいいけど、混在は許されないとのこと。
ドキュメントのなかで自動で判断されるとのこと
classに二つ以上したいしたいときは?
- %div{:class => ['y-3', 'p-3']}
- %div.y-3.p-3
- .y-3.p-3
ifの分岐ってどう書くの?
- if @engineer.engineer_hiring.nil?
.sl-row-rightAlign
.col-3
= button_tag '派遣元追加', type: 'button', onclick: 'addHiring'
-else
= f.fields_for :engineer_hiring do |e_hiring|
= render "engineer_hiring_form", hiring:e_hiring, office:@engineer.engineer_hiring.office
コメントってどうすればいい?
- HTMLでのコメント
- / を行頭につける
- / の後にインデントをつけると、その段落をまとめてコメントアウト
- Rubyのコメント
- -# を頭につける
-# = hidden_field "career-count", @engineer.careers.count + 1
これだとだめ
#= hidden_field "career-count", @engineer.careers.count + 1
これは大丈夫
=# hidden_field "career-count", @engineer.careers.count + 1
rubyのコード部分で改行はできるの?
rubyの仕様に準じるっぽい、以下はOK
= career.label :career_at,
Career.human_attribute_name("career_at")
= career.text_field :career_at