I wanted to use this immediately, so I wrapped it in a redmine plugin. There was a small trick needed, so here's the relevant code to be put, for example, in redmine_wt/lib/wt.rb and called from redmine_wt/init.rb using require_dependency.
# Dependency loading hell. http://www.ruby-forum.com/topic/166578#new
require 'dispatcher'
Dispatcher.to_prepare do
Redmine::WikiFormatting::Macros.class_eval do
# wiki template macro
desc "Replace token inside a template. Example:\n\n !{{template(WikiTemplatePage,token=foo,token2=bar)}}."
macro :template do |obj, args|
page = Wiki.find_page(args.shift.to_s, :project => @project)
raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
@included_wiki_pages ||= []
raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.title)
@included_wiki_pages << page.title
out = textilizable(page.content, :text, :attachments => page.attachments)
@included_wiki_pages.pop
args.collect do |v|
v[/(\w+)\W*\=\W*(.+)$/]
key = $1
value = $2.strip.gsub("<br />", "")
out = out.gsub(key, value)
end
out
end
end
end
I've not published this plugin, since it's so simple, but thought I should at least comment on this issue. Basically the above code is 90% Vianney's wiki_template.txt file, with a small wrapper based on code I saw in the init.rb of the task-board plugin by Dan Hodos.