Action View Context
Action View 前景會提供至 Action Controller 以呈現範本。預設 Action View 前景為 ActionView::Base
。
若要搭配 Action Controller 使用,Context
必須僅包含此模組。包含此模組的物件負責初始化前景所使用的變數 (@output_buffer、@view_flow 和 @virtual_path)(不過你可以叫用下列定義的 _prepare_context
)。
方法
屬性
[RW] | output_buffer | |
[RW] | view_flow |
指定作業中的公開方法
_layout_for(name = nil) 連結
封裝與檢視流程的互動作用,因此它會在 yield
上傳回正確的緩衝區。這通常會由 helper 覆寫以增加更多行為。
來源: 顯示 | 於 GitHub 上
# File actionview/lib/action_view/context.rb, line 27 def _layout_for(name = nil) name ||= :layout view_flow.get(name).html_safe end
_prepare_context() 連結
透過設定適當的指定作業變數來準備前景。
來源: 顯示 | 於 GitHub 上
# File actionview/lib/action_view/context.rb, line 18 def _prepare_context @view_flow = OutputFlow.new @output_buffer = ActionView::OutputBuffer.new @virtual_path = nil end