LoginSignup
5
4

More than 5 years have passed since last update.

f.date_select haml化 - haml化メモ

Last updated at Posted at 2015-12-19

erb => haml時の書き方がわからなかったので、実際にhaml化してみた

f.date_select haml化

元のhogehoge.html.erb
<%= form_for(@job) do |f| %>
    <div>
      <%= raw sprintf(f.date_select(:audition_date, use_month_numbers: true, start_year: (Time.now.year), end_year: (Time.now.year + 2), default: Time.now(), date_separator: '%s'), '年 ', '月 ') + '日' %>
    </div>
<% end %>
生成されたhtml.haml
= raw sprintf(f.date_select(:audition_date, use_month_numbers: true, start_year: (Time.now.year), end_year: (Time.now.year + 2), default: Time.now(),:class =>"bootstrap-date-only-width" ,date_separator: '%s'), '年 ', '月 ') + '日'

classの適用方法が分からないので困っています。どなかたご存知でしたらご教示頂けると幸いです。


hamlは便利だけど、毎回どうやって書けばいいのかわからなくなり悪戦苦闘しています。

ベースのerbのコードは下記を参考にさせていただきました
http://qiita.com/satomin/items/6a64280eb41c2881fa31

erb=>hamlは下記を参考にさせていただいています。
http://qiita.com/m_doi/items/1f01fd2b1a52c2c43f1f

5
4
2

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
5
4