Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

user macro different result using $helper.renderconfluencemacro directly and after storing in a variable

Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2014

Take a page containing an attachments macro.

Include it into another page using a user macro that writes the include as wiki markup and executes $helper.renderconfluencemacro

That works fine.

In the user macro, now store the result of $helper.renderconfluencemacro in a velocity variable, and print that, like this:

#set($macro="{include: ${paramName} }")
#set($page=$helper.renderConfluenceMacro($macro))
$page

The resulting page is now screwed up -- something happens in the middle of the attachments macro's output, and the rest of the page doesn't show.

I've examined the results with the Chrome debugger, and I don't see what is wrong. I didn't see any related errors in the console.

Anyone have an idea what is happening?

3 answers

1 accepted

0 votes
Answer accepted
Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2014

I was able to determine that a lot (though not all) of the problems are due to an iframe put in by the attachments macro. (As discovered by Davin, my problem only happens when drag-and-drop is turned on for tha macro). The offending line is:

<iframe class="plugin_attachments_uploadiframe hidden" name="haZWwwvlQLusX3zF97FMhgclmFMl4K5NcJrP6wljX5WaAYtE9qiZtY6pN7plcSHd" src="" />

If I remove this line from the included contents before printing, things go better. The display of this macro is still somewhat messed up, but the rest of the page prints.
0 votes
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

I don't think this part (${paramName}) is right. The $ should be next to the variable name.

Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

That is the shorthand notation (https://velocity.apache.org/engine/devel/user-guide.html#variables). The form with braces is for situations where the interpreter might get confused.

I think I said this, but: the code I gave works fine, except when the included page includes an "attachments" macro AND I store the result in a velicity variable before printing it. In that case only, the result is screwed up. When I saw "screwed up" I don't mean that it prints the velocity variable, I mean that there's something fairly subtle wrong with the output, so nothing past the attachments macro gets printed, including the page footer.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

Ok ... sorry I misread the question. Also, I didn't realize that was velocity syntax ... never had a reason to have the curly braces in it.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

I've tried replicating your issue with a user macro. I was able to get pages to include if there was an attachments macro on that page correctly only if the upload option was turned off for the attachments macro. If upload is turned on then it messed up. Is this the same issue you are having?

Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

Yes. I hadn't tried that -- turning off download in attachments does allow this to work. That is helpful, thanks.

0 votes
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

Hi Jonathan,

I think you need to use $action.helper.renderConfluenceMacro(...) in user macros. The following works for me:

## @noparams

#set($macro="{cheese}")
#set($page=$action.helper.renderConfluenceMacro($macro))
$page

Hope this helps.

Cheers
Remo

Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2014

I guess I wasn't clear enough -- I'm not having a problem running renderConfluenceMacro ($helper in my sample was set to $action.helper, I just didn't include that detail). As I mentioned, my code works fine as long as I print the output of the render directly, without first storing it in a velocity variable.

The problem is that I get a display failure if I store it in a variable and then print it.

You may be confused because I didn't say why I'd want to do that -- I left out that detail to simplify the problem. If you want to understand that, I want to manipulate the result before printing it. In testing why that wasn't working, I discovered that just storing in a variable was enough to screw up the output.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events