haml記法の練習
htmlの簡易記法であるhamlに慣れるための練習(imputメソッド)
%form{:method => "POST", :action => '/comment'}
%input{:type => "hidden", :name => "_method", :value => "PUT"}
%table
%tr
%td 名前
%td
%input{:type => "text", :name => "name"}
%tr
%td タイトル
%td
%input{:type => "text", :name => "title"}
%tr
%td 内容
%td
%textarea{:name => "message", :cols => 60, :rows => 8}
%tr
%td ラジオボタン
%td
%input{:type=> "radio", :name=> "sgnm", :value=>"p"} +
%input{:type=> "radio", :name=> "sgnm", :value=>"pm", :checked=>"checked" } ±
%input{:type=> "radio", :name=> "sgnm", :value=>"m"} -
%tr
%td チェックボックス
%td
%input{:type=> "checkbox", :name=> "sentaku", :value=>"A"}A
%input{:type=> "checkbox", :name=> "sentaku", :value=>"B"}B
%input{:type=> "checkbox", :name=> "sentaku", :value=>"C"}C
%input{:type=> "checkbox", :name=> "sentaku", :value=>"D"}D
%tr
%td
%td
%input{:type => "submit"}
- @comments.each do |comment|
.comment
%h2= h comment.title
.info
%span.name== by #{h comment.name}
%span.date== (#{h comment.date})
.message
= comment.formatted_message
次の画面のようになる。

技術的な覚書きへ戻る
4340
Keyword(s):[haml記法] [imputメソッド]
References:[技術的な覚書き]