Forums

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

How to get 'innerHTML' of $body inside a user macro

Robin M. Buck March 25, 2019

Dear all,

I try to make a user macro where hide different content based on a status text which is stored inside Status Handy.

 

<ac:structured-macro ac:macro-id="xxxxx" ac:name="status-handy" ac:schema-version="1">
<ac:parameter ac:name="Status">n/a</ac:parameter>
<ac:parameter ac:name="id">19969</ac:parameter>
</ac:structured-macro> <time datetime="2019-01-01"/>

 

so when Status is n/a i do not want to show a date.

 

With $body in the user macro, i only get the interpreted string, but not the HTML parsable string.

Any comments how to do so ?

## This is an example macro
## @param Search:title=Search term|type=string|required=true|desc=Enter your searchterm

#if($body.contains($paramSearch))
Found! "$body"
#else
Not found !
#end

thx

Robin

2 answers

0 votes
Bill Bailey
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.
March 26, 2019

This might be a good use case of wrapping that macro in a user macro so that it is easier to control. Where the user macro actually controls and inserts the second macro.

For an example of a wrapper macro, see Getting Started with User Macros - Writing a Wrapper Macro 

(Disclaimer, I am the author of the article.)

Robin M. Buck April 2, 2019

I tried to wrap that macro into a user macro. Actually its even this:

- User Macro 1: show final result
-- User Macro 2: so parse the HTML Content of the macro inside this macro
--- any Macro (e.g. status-handy)

 

But the problem is now, how can i modify the content inside the User Macro 2?
I feel more and more, that i need to develop an own macro using IDE.

Bill Bailey
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.
April 2, 2019

I think you are making it too hard. I would use the wrapper macro to set the parameter you need for the status-handy macro (plus any others). Then you can conditional show the macro based on that macro and now have to worry about parsing the body.

In the wrapper macro, there woudl be no body.

Robin M. Buck April 8, 2019

Thanks for your proposal...

0 votes
Aleksandr Zuevich
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.
March 25, 2019

Hi Robin,

 

Have you tried to change Macro Body Processing like Escaped or Unrendered?

Robin M. Buck April 2, 2019

Hi Aleksandr,

 

Unfortunately this is not working, because i need to have the HTML Content to parse the code inside another macro, but need to show then the final result.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events