擴充 ActionView
Rails提供了四種切入點可以讓你自行擴充Action View,分別是你可以擴充不同格式、不同Template引擎(Handler)、Renderer以及Resolver。這些都是非常進階的應用,初學者請逕行跳過此節。
Form builder
(TODO)
Format
自行擴充 Format,例如專給手機的 .iphone HTML 格式。
(TODO)
Handler
自行擴充 Handler,例如用 Prawn 產生 PDF。
(TODO)
http://blog.plataformatec.com.br/2011/06/multipart-templates-with-markerb/
Renderer
自行擴充 Renderer,例如render :csv => @people
(TODO)
Resolver
自行擴充 Template 的資料來源(預設是檔案),例如來自資料庫
http://blog.plataformatec.com.br/2011/04/default-views-in-rails-3-0-with-custom-resolvers/
(TODO)
Custom Pre-Processor
http://railstech.com/2011/08/custom-pre-processor-in-rails-3-1/ http://psionides.eu/2012/05/06/extending-asset-pipeline-with-custom-preprocessors/
Presenter 模式
對於專業的開發者, 在遇到複雜的 template 時, ERb 或 HAML 可能力有未逮, 這時候可以引進 Presener pattern,… 適合的情境是…. 方法是…..
(TODO)