突然出てくる.erbファイル。Embedded RuByの略なのね。納得。
<table class="table table-hover boards__table"> <thead class="thead-dark"> <tr> <th>ID</th> <th>タイトル</th> <th>作成者</th> <th>作成日時</th> <th>更新日時</th> </tr> </thead> <tbody> <% @boards.each do |board| %> <tr> <th><%= board.id %></th> <td><%= board.title %></td> <td><%= board.name %></td> <td><%= board.created_at %></td> <td><%= board.updated_at %></td> </tr> <% end %> </tbody> </table>
シンタックスは結構単純。
<%= EXPRESSION %>
— Inserts the value of an expression.- With
-%>
— Trims the following line break.
- With
<% CODE %>
— Executes code, but does not insert a value.- With
<%-
— Trims the preceding indentation. - With
-%>
— Trims the following line break.
- With
<%# COMMENT %>
— Removed from the final output.- With
-%>
— Trims the following line break.
- With
<%%
or%%>
— A literal<%
or%>
, respectively.