Index: lib/redmine/hook.rb
===================================================================
--- lib/redmine/hook.rb	(Revision 2352)
+++ lib/redmine/hook.rb	(Arbeitskopie)
@@ -17,6 +17,8 @@
 
 module Redmine
   module Hook
+    include ActionController::UrlWriter
+
     @@listener_classes = []
     @@listeners = nil
     @@hook_listeners = {}
@@ -55,11 +57,17 @@
       # Calls a hook.
       # Returns the listeners response.
       def call_hook(hook, context={})
-        response = ''
-        hook_listeners(hook).each do |listener|
-          response << listener.send(hook, context).to_s
+        returning [] do |response|
+          hls = hook_listeners(hook)
+          if hls.any?
+            request = context[:request]
+            if request
+              default_url_options[:host] ||= request.env["SERVER_NAME"]
+              default_url_options[:port] ||= request.env["SERVER_PORT"]
+            end
+            hls.each {|listener| response << listener.send(hook, context)}
+          end
         end
-        response
       end
     end
 
@@ -91,6 +99,12 @@
       include ActionView::Helpers::TextHelper
       include ActionController::UrlWriter
       include ApplicationHelper
+
+      def self.render_on(hook, options={})
+        define_method hook do |context|
+          context[:controller].send(:render_to_string, {:locals => context}.merge(options))
+        end
+      end
     end
 
     # Helper module included in ApplicationHelper so that hooks can be called
@@ -101,7 +115,13 @@
     # Current project is automatically added to the call context.
     module Helper
       def call_hook(hook, context={})
-        Redmine::Hook.call_hook(hook, {:project => @project}.merge(context))
+        if is_a?(ActionController::Base)
+          ctx = {:controller => self, :project => @project, :request => request}
+          Redmine::Hook.call_hook(hook, ctx.merge(context))
+        else
+          ctx = {:controller => controller, :project => @project, :request => request}
+          Redmine::Hook.call_hook(hook, ctx.merge(context)).join
+        end        
       end
     end
   end
Index: test/unit/lib/redmine/hook_test.rb
===================================================================
--- test/unit/lib/redmine/hook_test.rb	(Revision 2352)
+++ test/unit/lib/redmine/hook_test.rb	(Arbeitskopie)
@@ -67,17 +67,17 @@
   
   def test_call_hook
     @hook_module.add_listener(TestHook1)
-    assert_equal 'Test hook 1 listener.', @hook_module.call_hook(:view_layouts_base_html_head)
+    assert_equal ['Test hook 1 listener.'], @hook_module.call_hook(:view_layouts_base_html_head)
   end
   
   def test_call_hook_with_context
     @hook_module.add_listener(TestHook3)
-    assert_equal 'Context keys: bar, foo.', @hook_module.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a')
+    assert_equal ['Context keys: bar, foo.'], @hook_module.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a')
   end
   
   def test_call_hook_with_multiple_listeners
     @hook_module.add_listener(TestHook1)
     @hook_module.add_listener(TestHook2)
-    assert_equal 'Test hook 1 listener.Test hook 2 listener.', @hook_module.call_hook(:view_layouts_base_html_head)
+    assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], @hook_module.call_hook(:view_layouts_base_html_head)
   end
 end
