Search
Project
General
Profile
Home
Projects
Help
Sign in
Register
Search
:
Redmine
All Projects
Redmine
Overview
Download
Activity
Roadmap
Issues
News
Wiki
Plugins
Forums
Repository
Download (860 Bytes)
Feature #2854
ยป wiki_template.txt
Vianney Lecroart
, 2009-02-27 09:53
# 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
(1-1/1)
Loading...