lib/hypertemplate/hook/rails.rb in hypertemplate-1.2.1 vs lib/hypertemplate/hook/rails.rb in hypertemplate-1.2.2
- old
+ new
@@ -1,25 +1,25 @@
require 'hypertemplate' unless defined? ::Hypertemplate
module Hypertemplate
module RegistryContainer
-
+
def hypertemplate_registry
@hypertemplate || use_hypertemplate
end
-
+
def use_hypertemplate(&block)
@hypertemplate = ::Hypertemplate::Registry.new
if block_given?
yield @hypertemplate
else
@hypertemplate << ::Hypertemplate::Builder::Json
@hypertemplate << ::Hypertemplate::Builder::Xml
end
@hypertemplate
end
-
+
end
end
module ActionController
class Base
@@ -29,14 +29,13 @@
module Hypertemplate
module Hook
module Rails
- class Hypertemplate < ::ActionView::TemplateHandler
- include ::ActionView::TemplateHandlers::Compilable
+ class Hypertemplate
- def compile(template)
+ def self.call(template)
"@content_type_helpers = controller.hypertemplate_registry[self.response.content_type].helper; " +
"extend @content_type_helpers; " +
"extend Hypertemplate::Hook::Rails::Helpers; " +
"code_block = lambda { #{template.source} };" +
"builder = code_block.call; " +
@@ -54,18 +53,18 @@
end
self
end
end
end
-
+
module Helpers
def self.extend_object(base)
super
base.extend(Rails3Adapter) unless base.respond_to?(:_pick_partial_template)
end
-
+
# Load a partial template to execute in describe
#
# For example:
#
# Passing the current context to partial in template:
@@ -106,10 +105,10 @@
end
end
end
private
-
+
def self.registry
if defined? ::ActionView::Template and ::ActionView::Template.respond_to?(:register_template_handler)
::ActionView::Template
else
if defined? ::ActionController::Base