diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-16 15:34:17 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-16 15:34:17 +0000 |
commit | 05823373724e472b6b7f9f172733aa16d132ced7 (patch) | |
tree | 041df1af3919b5ecfd9f84a9f86af5ce207c7370 /lib/redmine/wiki_formatting | |
parent | 1c8cf4ef8338736ebcaa905f8932545a24e817c6 (diff) | |
download | redmine-05823373724e472b6b7f9f172733aa16d132ced7.tar.gz redmine-05823373724e472b6b7f9f172733aa16d132ced7.zip |
Added:
* the 'include' macro to include a wiki page
* macro escaping support (with exclamation mark)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1153 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting')
-rw-r--r-- | lib/redmine/wiki_formatting/macros.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index f9920afdb..c0f2b222a 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -62,7 +62,7 @@ module Redmine end # Builtin macros - desc "Example macro." + desc "Sample macro." macro :hello_world do |obj, args| "Hello world! Object: #{obj.class.name}, " + (args.empty? ? "Called with no argument." : "Arguments: #{args.join(', ')}") end @@ -72,10 +72,27 @@ module Redmine out = '' @@available_macros.keys.collect(&:to_s).sort.each do |macro| out << content_tag('dt', content_tag('code', macro)) - out << content_tag('dd', simple_format(@@available_macros[macro.to_sym])) + out << content_tag('dd', textilizable(@@available_macros[macro.to_sym])) end content_tag('dl', out) end + + desc "Include a wiki page. Example:\n\n !{{include(Foo)}}" + macro :include do |obj, args| + if @project && !@project.wiki.nil? + page = @project.wiki.find_page(args.first) + if page && page.content + @included_wiki_pages ||= [] + raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.title) + @included_wiki_pages << page.title + out = textilizable(page.content, :text) + @included_wiki_pages.pop + out + else + raise "Page #{args.first} doesn't exist" + end + end + end end end end |