LoginSignup
1
1

More than 5 years have passed since last update.

hamlを使うための覚え書き on RubyMine2018.3

Last updated at Posted at 2018-09-16

Ruby-mineはhamlの補完機能とかあって、快適です。
何故かテンプレートが用意されていないのは気持ち悪いけど。。

とりあえず、設定としてはこんな感じで今のところはストレスレス

image.png

ドキュメント

迷ったところ

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

1
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1