Hi guys,
I started dabbling in user macros and I'm having some issues with parsing the content of a table.
Basically my macro is a wrapper around another one (page properties report) which outputs an html table. I'm using .split with </tr> but if I try to output the parsed content, it looks like Confluence renders the HTML. So I end up with what I think is the bare value of a cell, but in reality it contains a lot more garbage such as spans, etc.
E.g. in the page I see the text "draft", but if I measure the length of the string is like 335...
Any suggestion?
Please note that I know very little of coding...
Thanks!
Hi Bill,
The body is rendered, but I didn't know you could escape the output.
This is a snippet:
#set($myTrainingBody=$body.split("</thead>")) ## Isolate table headers
#foreach ($string in $myTrainingBody)
#set($xxx = $myTrainingTemp.add($string))
##<p> $string </p>
#end
##$myTrainingTemp
#set($myTrainingLine=$myTrainingTemp.get(0)) ## Get headers
##Line $myTrainingLine
#set($myTrainingRow=$myTrainingLine.split("</th>"))
#foreach($data in $myTrainingRow)
#set($xxx = $myTrainingPageProperties.add($data))
#set($j = $j + 1)
#end
#set($xxx=$myTrainingMatrix.add($myTrainingPageProperties))
#foreach($point in [1..$j])
#set($xxx = $myTrainingPageProperties.remove(0))
#end
#set($j = 0)
#set($myTrainingLine=$myTrainingTemp.get(1)) ## Disregard headers
##Line $myTrainingLine
#set($myTrainingRow=$myTrainingLine.split("</tr>"))
#foreach ($string in $myTrainingRow)
#set($xxx = $myTrainingRowT.add($string))
##<p>String $string </p>
#end
#foreach($entry in $myTrainingRowT)
#set($line = $myTrainingRowT.get($i))
#set($i = $i + 1)
#set($tempLine=$line.split("</td>"))
#foreach($data in $tempLine)
#set($xxx = $myTrainingPageProperties.add($data))
#set($j = $j + 1)
#end
#set($xxx=$myTrainingMatrix.add($myTrainingPageProperties))
##<p>Page Properties $myTrainingPageProperties</p>
#foreach($point in [1..$j])
#set($xxx = $myTrainingPageProperties.remove(0))
#end
#set($j = 0)
#end
_____________________________
When I access one of the data in $myTrainingMatrix, although the output may be something just like "Draft", the length of the string is like 301.
Well it would be best to post your code if possible, and then a screencap of what is happening (and did you set the output to be escaped or rendered).
I will give you one warning though. I have created a wrapper macro around the page properties macro. It displayed OK on the page, but I was unable to pull the value with page properties report macro (I think there a bug was filed for this).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you are nesting the page properties macro inside your user macro?
My suggestion is to write a wrapper macro around the page properties macro (i,e,, your user macro uses parameters to configure the macro. Then you do not need to parse it.
Take a look at this article I wrote to see if this concept would work for you: Getting-Started-with-User-Macros-Writing-a-Wrapper-Macro The idea it to come at the issue orthogonality.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
I read your article, but how can I then use the output of the page properties macro? I need to pick values in certain cells and based on their value trigger some behavior.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well the user would select or enter the value when inserting the macro. At that point, that setting is saved to a variable that you can use elsewhere in the code.
So in my macro code, the user parameter is set here:
## @param Priority:title=Priority|type=enum|enumValues=Critical,High,Medium,Low
Now you can use this value in its variable form
$paramPriority
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
I should have explained the situation a bit better, my bad.
The Page Properties Report macro pulls certain values from pages in another space.
I need to get the values reported by the macro in a certain column and manipulate them. I don't really need a pure wrapper, as the inputs to the Properties Report macro don't change.
Thanks for your help
Matteo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I missed that. Let me think about it. You should be able to pull the values as java objects,. i.e., not use the report macro at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Take a look at this question here. It should point you in the right direction as far as searching for a solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.