From efc5d188719618c00748255726515f228378a390 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 7 Aug 2008 18:43:22 +0000 Subject: [PATCH] Automatically add current project to the context of hook calls in views. git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1718 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- hooks/lib/redmine/hook.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hooks/lib/redmine/hook.rb b/hooks/lib/redmine/hook.rb index fecdfed9a..79961b2bb 100644 --- a/hooks/lib/redmine/hook.rb +++ b/hooks/lib/redmine/hook.rb @@ -104,9 +104,11 @@ module Redmine # in views like this: # <%= call_hook(:some_hook) %> # <%= call_hook(:another_hook, :foo => 'bar' %> + # + # Current project is automatically added to the call context. module Helper def call_hook(hook, context={}) - Redmine::Hook.call_hook(hook, context) + Redmine::Hook.call_hook(hook, {:project => @project}.merge(context)) end end end @@ -114,3 +116,9 @@ end ApplicationHelper.send(:include, Redmine::Hook::Helper) +class Hello < Redmine::Hook::ViewListener + def view_layouts_base_html_head(context) + context[:project].to_s + end +end +