lib/hypertemplate/hook/rails.rb in hypertemplate-1.2.0 vs lib/hypertemplate/hook/rails.rb in hypertemplate-1.2.1

- old
+ new

@@ -33,19 +33,38 @@ class Hypertemplate < ::ActionView::TemplateHandler include ::ActionView::TemplateHandlers::Compilable def compile(template) - "@content_type_helpers = @controller.hypertemplate_registry[self.response.content_type].helper; " + + "@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; " + "builder" end end + module Rails3Adapter + def _pick_partial_template(path) #:nodoc: + return path unless path.is_a?(String) + prefix = controller_path unless path.include?(?/) + find_template(path, prefix, true).instance_eval do + unless respond_to?(:path) + def path; virtual_path end + 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: