Project

General

Profile

Feature #4372 ยป include-macro-version.patch

Oskar Nordquist, 2009-12-16 13:05

View differences:

lib/redmine/wiki_formatting/macros.rb (working copy)
desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}"
macro :include do |obj, args|
page = Wiki.find_page(args.first.to_s, :project => @project)
title = args.first.to_s
if title =~ %r{^([^@]+)@(.*)$}
title, version = $1, $2
end
page = Wiki.find_page(title, :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)
content = version ? page.content_for_version(version) : page.content
out = textilizable(content, :text, :attachments => page.attachments)
@included_wiki_pages.pop
out
end
    (1-1/1)