📄 02 - creating a layout for your header and footer.rb
字号:
<html> <head> <title>My Website</title> </head> <body> <%= @content_for_layout %> </body></html>#---class StatusController < ActionController:Base def index @title = "System Status" endend#---<html> <head> <title>My Website - <%= @title %></title> </head> <body> <%= @content_for_layout %> </body></html>#---class FooController < ActionController:Base # Force the layout for /foo to be app/views/layouts/bar.rhtml, # not app/view/layouts/foo.rhtml. layout 'bar'end#---class FooController < ActionController:Base layout 'bar' def count @data = [1,2,3] render :layout => 'count' endend#---class FooController < ActionController:Base layout 'bar', :except => 'count'end#---class FooController < ActionController:Base layout :figure_out_layout private def figure_out_layout if action_name =~ /pretty/ 'pretty' # use pretty.rhtml for the layout else 'standard' # use standard.rhtml end endend#---class FooController < ActionController:Base layout lambda { |controller| controller.logged_in? ? 'user' : 'guest' }end#---<%= render :partial => 'layouts/header' %>... your view's content goes here ...<%= render :partial => 'layouts/footer' %>#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -