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
@@ -99,13 +113,21 @@
     #   <%= call_hook(:another_hook, :foo => 'bar' %>
     # 
     # Current project is automatically added to the call context.
-    module Helper
+    module ApplicationHelperMethods
       def call_hook(hook, context={})
-        Redmine::Hook.call_hook(hook, {:project => @project}.merge(context))
+        ctx = {:controller => controller, :project => @project, :request => request}
+        Redmine::Hook.call_hook(hook, ctx.merge(context)).join
       end
     end
+
+    module ActionControllerMethods
+      def call_hook(hook, context={})
+        ctx = {:controller => self, :project => @project, :request => request}
+        Redmine::Hook.call_hook(hook, ctx.merge(context))
+      end
+    end
   end
 end
 
-ApplicationHelper.send(:include, Redmine::Hook::Helper)
-ActionController::Base.send(:include, Redmine::Hook::Helper)
+ApplicationHelper.send(:include, Redmine::Hook::ApplicationHelperMethods)
+ActionController::Base.send(:include, Redmine::Hook::ActionControllerMethods)
