From bc4d05b244c78f03ade51d8b95f16dd48ceb63d3 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 23 Nov 2008 13:57:01 -0600 Subject: A back support for legacy TemplateHandler#render API --- actionpack/lib/action_view/template_handler.rb | 29 +++++++++++++++++++++++-- actionpack/lib/action_view/template_handlers.rb | 4 ---- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/template_handler.rb b/actionpack/lib/action_view/template_handler.rb index 5efe9459b5..672da0ed2b 100644 --- a/actionpack/lib/action_view/template_handler.rb +++ b/actionpack/lib/action_view/template_handler.rb @@ -1,9 +1,34 @@ # Legacy TemplateHandler stub - module ActionView + module TemplateHandlers #:nodoc: + module Compilable + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + def call(template) + new.compile(template) + end + end + + def compile(template) + raise "Need to implement #{self.class.name}#compile(template)" + end + end + end + class TemplateHandler def self.call(template) - new.compile(template) + "#{name}.new(self).render(template, local_assigns)" + end + + def initialize(view = nil) + @view = view + end + + def render(template, local_assigns) + raise "Need to implement #{self.class.name}#render(template, local_assigns)" end end end diff --git a/actionpack/lib/action_view/template_handlers.rb b/actionpack/lib/action_view/template_handlers.rb index 1052c4e75c..d06ddd5fb5 100644 --- a/actionpack/lib/action_view/template_handlers.rb +++ b/actionpack/lib/action_view/template_handlers.rb @@ -4,10 +4,6 @@ module ActionView #:nodoc: autoload :RJS, 'action_view/template_handlers/rjs' autoload :Builder, 'action_view/template_handlers/builder' - # Legacy Compilable stub - module Compilable - end - def self.extended(base) base.register_default_template_handler :erb, TemplateHandlers::ERB base.register_template_handler :rjs, TemplateHandlers::RJS -- cgit v1.2.3