| Name | Replace and Render |
|---|---|
| Vendor | Adaptavist.com Ltd (Website) |
| Authors | Alain Moran |
| Homepage | http://confluence.atlassian.com/display/CONFEXT/Replace+and+Render+Plugin |
| Issue Management | http://jira.adaptavist.com/browse/RNR |
| Categories | Formatting Macros |
| Version | 0.2 |
| Availability | Confluence v2.1 to v2.10-m1 |
| State | Alpha |
| Support |
|
| License | Freeware / Open Source (BSD) |
| Price | Donate |
| Release Docs | http://confluence.atlassian.com/display/CONFEXT/Replace+and+Render+Plugin |
| Java API Docs | n/a |
| Download Source | n/a |
| Download JAR | adaptavist-plugin-replaceandrender-0.2.jar |
Description/Features
Allows replacements to be made within a block of wiki markup
Usage
{replace-and-render}
{replace-body}{div:align=%alignment%}this is some text{div}{replace-body}
{replace-item:%alignment%}center{replace-item}
{replace-and-render}
Examples
{replace-and-render}
{replace-body}{%mymacro%}this is the replace body with a %replaceme%{%mymacro%}{replace-body}
{replace-item:%replaceme%}replacement{replace-item}
{replace-item:%mymacro%}center{replace-item}
{replace-and-render}
{velocity-render:parameter=value}
#set($varible="value")
variable = $variable
parameter = $parameter
#foreach($a in ['a','b','c'])
$velocityCount : $a </br>
#end
...etc...
{velocity-render}
Version History
Open Issues
|
|
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| T | Key | Summary | Assignee | Reporter | Pr | Status | Res | Created | Updated | Due |
|
|
RNR-11 | Replace and render will not install in Confluence 2.9 | Alain Moran | Tony Atkins |
|
|
UNRESOLVED | Aug 11, 2008 | Sep 08, 2008 | |
|
|
RNR-10 | replace-body seems borked with confluence 2.9 | Huw Evans | Guy Fraser |
|
|
UNRESOLVED | Aug 08, 2008 | Aug 08, 2008 | |
|
|
RNR-9 | Allow replace-item to use macro parameters | Alain Moran | Nick Waanders |
|
|
UNRESOLVED | May 19, 2008 | May 19, 2008 | |
|
|
RNR-8 | some kind of noformat or text-only option for replace-and-render / replace-item | Alain Moran | Christian Nesemann |
|
|
UNRESOLVED | Apr 22, 2008 | Apr 22, 2008 | |
|
|
RNR-7 | xml | Alain Moran | alex |
|
|
UNRESOLVED | Mar 15, 2008 | Mar 15, 2008 | |
|
|
RNR-1 | simple change could allow 'foreach' capability | Alain Moran | None |
|
|
UNRESOLVED | Feb 08, 2007 | Feb 08, 2007 | |
Screenshots
Screenshots |
|---|
| There are no images attached to this page |


Comments (42)
Jan 23, 2007
James Mortimer says:
there is no pid for jira, so I've added my comments here: 1) link from annotati...there is no pid for jira, so I've added my comments here:
1) link from annotation guide documentation is incorrect:
gives: http://www.adaptavist.com/display/USERGUIDE/replace-and-render+macro
should be:
http://confluence.atlassian.com/display/CONFEXT/Replace+and+Render+Plugin
2) http://jira.adaptavist.com/browse/RNR is invalid
3) replace and render no longer exists on adaptavist site that I could find, by search or by index into their custom macros
4) feature request:
5) feature request:
content
will replace any occurance of key with value in content and render the content as wiki.
Jan 24, 2007
Alain Moran says:
1: Yes, for now the context help will have to suffice I'm a little busy with oth...1: Yes, for now the context help will have to suffice I'm a little busy with other projects to write the docs up ... sorry
2: JIRA project created.
3: As I say .. I havent had time to write the docs up yet, since this was a throwaway 'lunchtime' creation that was intended as a way of working out one way that this kind of thing could be done.
4: the output from the
5: As bob rightly says, this is the syntax of the run macro which should be used instead.
Mar 21, 2007
James Mortimer says:
I couldn't get this to work with {include} as it seems to render the content int...I couldn't get this to work with {include} as it seems to render the content into html first in my attempt.
I can't find any references for an {import} macro, but that might work if indeed it imports wiki rather than html.
Mar 21, 2007
James Mortimer says:
{replace-and-render} {replace-item:%test%}James{replace-item} {replace-body} ...{replace-and-render} {replace-item:%test%}James{replace-item} {replace-body} |Include |{include:replace-and-render-included-page}| |Import |{import:replace-and-render-included-page}| |metadata-from|{metadata-from:replace-and-render-included-page|test}| |zone-template-instance|{zone-template-instance:replace-and-render-included-page}{zone-template-instance}| {replace-body} {replace-and-render}replace-and-render-included-page contains
Mar 21, 2007
Alain Moran says:
Ah, yeah, you are correct ... they would need to include the wiki text and not t...Ah, yeah, you are correct ... they would need to include the wiki text and not the html .. my mistake.
Jan 23, 2007
James Mortimer says:
example was: {replace-and-render:key=value}content{replace-and-render}example was:
{replace-and-render:key=value}content{replace-and-render}Jan 24, 2007
Alain Moran says:
aha ... it would appear that bob intended to insert his comment here, since this...aha ... it would appear that bob intended to insert his comment here, since this is exactly what the run macro does
Jan 23, 2007
Bob Swift says:
This has some overlap with the Run macro.This has some overlap with the Run macro.
Jan 24, 2007
James Mortimer says:
major differences substitutions are done in the macro body in sub-tags, so tha...major differences
recommend:
-
will cross post this to the run page.-Jan 24, 2007
Alain Moran says:
The intention of replace-and-render was to allow the output of one macro to be f...The intention of replace-and-render was to allow the output of one macro to be fed into the arguments of another, which doesnt appear to be possible with the run macro.
Jan 24, 2007
Bob Swift says:
Well, Run macro certainly does that. It's main purpose was to allow for the use...Well, Run macro certainly does that. It's main purpose was to allow for the user to provide input (parameters) that could then be used to drive other macros like sql for instance. As far as substitutions, | is the only restrictions due to the parsing Confluence does (as an aside, I think that could be improved
). All that said, I think James' suggestion to harmonize is appropriate and something we can sort out in the future. Run macro is still in beta partly because of the need to make changes (that may be incompatible) as a result of feedback.
Jan 24, 2007
Alain Moran says:
Heh .. I mean as in take the output of a macro and inject it as a parameter, eg:...Heh .. I mean as in take the output of a macro and inject it as a parameter, eg:
{replace-and-render} {replace-body} {show-to:users=%participants%} This text is only visible to those people who have contributed to the page. {show-to} {replace-body} {replace-item:%participants%}{page-info:participants|type=flat}{replace-item} {replace-and-render}I'm not sure how that could be achieved with the run macro.
Jan 24, 2007
Bob Swift says:
I see what you mean, yes, that is quite different and useful. Even so, there mi...I see what you mean, yes, that is quite different and useful. Even so, there might be some things we could harmonize. James created an issue RUN-5 where we can discuss further. One obvious area is how to identify replacement variables.
Jan 25, 2007
James Mortimer says:
interesting and important use case above that I neglected in my first list of di...interesting and important use case above that I neglected in my first list of disctinct differences between run and replace-and-render
Chould almost be called 'render-then-replace-and-render-again'.
The hack macro I had written to do the same was just called {replace}, but {replace-and-render} encompases it's entire functionality so I will discontinue development for now. I didn't even get a chance to post it yet.
Feb 08, 2007
James Mortimer says:
Run macro is now Run PluginRun macro is now Run Plugin
Feb 08, 2007
James Mortimer says:
A great extension to the [replace-and-render plugin] which would differe...A great extension to the [replace-and-render plugin] which would differentiate it from the Run Plugin would be a 'foreach' capability: For example:
{foreach} {foreach-head} || Item || Link || Page Titles || Labelled Pages || {foreach-head} {foreach-tail}{foreach-tail} {foreach-body} || %item% | [%item%] | {search:query=title:%item%} | {contentbylabel:%item%} | {foreach-body} {foreach-list:%item%} alpha beta gamma {foreach-list} {foreach}that would render a table with 4 rows and the obvious replacements
But this could be a fairly simple patch to replace-and-render that includes a new tag,
Feb 08, 2007
Alain Moran says:
You would use the {velocity-render} macro for this kind of thingYou would use the {velocity-render} macro for this kind of thing
Mar 21, 2007
James Mortimer says:
There are two very useful macros, Zones Plugin and Replace and Render Plugin, wh...There are two very useful macros, Zones Plugin and Replace and Render Plugin, which were once-offs and Alain and Jason don't have time to support / extend them. Perhaps you or the community would combine them, as they are essentially the same thing, except:
Both are very simple, and very useful, and provide fundamental functionality missing from Confluence.
Currently, I almost always use both together because of each's deficiencies and strengths (a replace-and-render, wrapped in a zone-template)
replace-and-render would be redundant if:
a) zones supported the {zone-data:%var%}value{zone-data} or {zone-data:$var}value{zone-data} syntax for replacing %var% and $var, respectively, for use in macro parameters
b) supported a {zone-body}body{zone-body} tag which, if present, would override the parameter to zone-template-instance that looked for the body on another page.
zone-templates would be redundant if:
a) replace and render could optionally get it's body from the replace-body tag (as it does currently), or from a remote page using {replace-and-render:space:page} or {replace-and-render:body=space:page}
(They also have some overlap with the Run macro. See discussion above.)
http://developer.atlassian.com/jira/browse/ZONE-15
Thanks guys, for two essential plugins!
Mar 21, 2007
James Mortimer says:
http://jira.adaptavist.com/browse/RNR-5http://jira.adaptavist.com/browse/RNR-5
Apr 07, 2007
Olivier Oswald says:
By using the replace-and-render plugin in combination with the html plugin, you'...By using the replace-and-render plugin in combination with the html plugin, you're able to create new pages based on form values. The following example shows two dropdown lists on the current page allowing the user to select a month and year. By clicking on the Create Status Report button, a JavaScript is called which redirects the browser to Confluence's "add page" dialog with a predefined title.
{replace-and-render} {replace-body} {html} <br><select id="cboStatusReportMonth"> <option></option> <option>January</option><option>February</option><option>March</option><option>April</option> <option>May</option><option>June</option><option>July</option><option>August</option> <option>September</option><option>October</option><option>November</option><option>December</option> </select> <select id="cboStatusReportYear"> <option>2006</option><option selected>2007</option><option>2008</option><option>2009</option> </select> <input type="button" value="Create Status Report" onclick="createStatusReport();"> <script language="JavaScript"> function createStatusReport() { var spaceKey = "%spaceKey%"; var fromPageId = "%pageId%"; var projectName = "%pageTitle%"; var boilerplate = "%boilerPlate%"; var monthText = document.getElementById('cboStatusReportMonth').value; var yearText = document.getElementById('cboStatusReportYear').value; if (monthText.length>0 && yearText.length>0) { var title = "Status Report for '" + projectName + "' - " + monthText + " " + yearText; document.location = "/pages/createfromboilerplate.action?spaceKey=" + escape(spaceKey) + "&linkCreation=true&title=" + escape(title) + "&fromPageId=" + fromPageId + "&parentPageString=" + escape(projectName) + "&boilerplate=" + escape(boilerplate);; } else { alert("Please select a month and year."); } } </script> {html} {replace-body} {replace-item:%pageId%}{page-info:pageId}{replace-item} {replace-item:%pageTitle%}{page-info:title}{replace-item} {replace-item:%spaceKey%}PRJ{replace-item} {replace-item:%boilerPlate%}StatusReport{replace-item} {replace-and-render}There's a known issue with this method: although the title of the new page is specified, Confluence still displays the "add page" dialog with the title text box disabled, leaving the user the only option to either click "Save" to finally create the page - or to cancel the process. This is not very user friendly, but seems to be the only option for the moment.
Apr 10, 2007
Alain Moran says:
If you take apart the create-page macro, then you should find another action whi...If you take apart the create-page macro, then you should find another action which will be more friendly to the kind of things you are doing here.
Jul 11, 2007
David Peterson [CustomWare] says:
By the way, if you remove the '&linkCreation=true' parameter from the URL, y...By the way, if you remove the '&linkCreation=true' parameter from the URL, you will be able to edit the page title.
Feb 28, 2008
Sean V says:
This is exactly what I was looking for, but alas, it doesn't work in IE (it does...This is exactly what I was looking for, but alas, it doesn't work in IE (it does in Firefox, though).
The problem lines seem to be those below. These vars just aren't getting set (they're empty).
var monthText = document.getElementById('cboStatusReportMonth').value;
var yearText = document.getElementById('cboStatusReportYear').value;
Anyone with more than my cursory understanding of Javascript know what's going on?
Mar 03, 2008
Sean V says:
Looks like I finally figured out the IE glitch. The trick is to break each of th...Looks like I finally figured out the IE glitch. The trick is to break each of the problem lines above into two. See the code below (note that this version if for weekly status reports, so it's a bit different from above):
{replace-and-render} {replace-body} {html}Week Ending: <select id="cboStatusReportWeek"> <option></option> <option>02-29-2008</option> <option>03-07-2008</option> <option>03-14-2008</option> <option>03-21-2008</option> <option>03-28-2008</option> <option>04-04-2008</option> <option>04-11-2008</option> <option>04-18-2008</option> <option>04-25-2008</option> </select> <input type="button" value="Add a Weekly Status Report" onclick="createStatusReport();"> <script language="JavaScript"> function createStatusReport() { var spaceKey = "%spaceKey%"; var fromPageId = "%pageId%"; var projectName = "%pageTitle%"; var boilerplate = "%boilerPlate%"; var weekMenu = document.getElementById("cboStatusReportWeek"); var weekText = weekMenu.options[weekMenu.selectedIndex].text; if (weekText.length>0) { var title = projectName + ", " + weekText; document.location = "/pages/createfromboilerplate.action?spaceKey=" + escape(spaceKey) + "&linkCreation=true&title=" + escape(title) + "&fromPageId=" + fromPageId + "&parentPageString=" + escape(projectName) + "&boilerplate=" + escape(boilerplate); } else { alert("Please select a week."); } } </script> {html} {replace-body} {replace-item:%pageId%}{page-info:pageId}{replace-item} {replace-item:%pageTitle%}{page-info:title}{replace-item} {replace-item:%spaceKey%}YPCBizIpedia{replace-item} {replace-item:%boilerPlate%}Weekly Status Template{replace-item} {replace-and-render}Mar 04, 2008
Olivier Oswald says:
thanx sean. been travelling for the last four months and didn't find the time to...thanx sean. been travelling for the last four months and didn't find the time to respond.
May 30, 2007
Olivier Oswald says:
How do I properly replace a value in report-table generated content? I would lik...How do I properly replace a value in report-table generated content? I would like to replace the table's <thead> element with a <tr> element in order to work around a bug of the table-plus macro. The following code does not work. Does replace-and-render first replace, then render the content?
{replace-and-render} {replace-item:thead}tr{replace-item} {replace-body} {report-table} {content-reporter:scope=@self > children|types=page|labels=todo} {date-sort:data:DueDate} {content-reporter} {report-column:title=Task}{report-info:data:Task}{report-column} {report-column:title=Due Date}{report-info:data:DueDate}{report-column} {report-table} {replace-body} {replace-and-render}May 30, 2007
David Peterson [CustomWare] says:
Unfortunately, {replace-and-render} won't help you with this. As implied by the ...Unfortunately, {replace-and-render} won't help you with this. As implied by the name of the macro, it first replaces, then renders, which means you can't do any replacements on the HTML code generated by the rendering engine.
I wasn't aware that there was a specific bug with the table-plus macro, but my suggestion would be to fix the bug, rather than try to hack around it. Incidentally, if you replaced <thead> with <tr> you would probably still have problems, since the <thead> already contains a <tr>.
May 31, 2007
Olivier Oswald says:
correct, should have spent more time on this. here's the bug report on table-plu...correct, should have spent more time on this. here's the bug report on table-plus.