view原理
ActionView: actionview gem
ActionController : actionpack gem
actionview和actionpack都可以单独应用于任何ruby项目
view的查找
app/views
view的分类
Template: index.html.erb
Partial: _user.html.erb
Layouts: application.html.erbapp/views
View的解析
ERB
HAML
Builder: json builder, xml builder etc.
都是完成Ruby语法到字符串的解释
ERB
<% %> # => 没有输出,用于循环,遍历,赋值等操作
<%= %> # => 输出内容
<% @users.each do |user| %>
<p><%= user.username %></p>
<% end -%>
ERB
<% a = 1 %>
<%= a %> # => 1
# 注释
<%# hello world %>
View的命名
index.html.erb
index: action对应的名称 / partial名称
html: 输出文件类型(mime type)
erb: 解释引擎