Forums

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

How do I get "<time datetime="2019-01-01"/>" working in my confluence xhtml macro?

Marcel Ortlieb
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 15, 2019

I defiened a very basic xhtml macro for setting a date value which I want to be converted to date picker storage format (resp. date lozenge).

xhtml macro definition:

<xhtml-macro name="helloworld" class="com.atlassian.tutorial.anotherNewPlugin.macro.helloworld" key='helloworld-macro' hide-body="true">
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters>
<parameter name="Date" type="string"/>
</parameters>
</xhtml-macro>

helloworld.java

public class helloworld implements Macro {

public String execute(Map<String, String> map, String s, ConversionContext conversionContext) throws MacroExecutionException {

String date;
String result = "";

if (map.get("Date") != null) {
date = map.get("Date");
result = "<time datetime=\"" + date + "\"></time>";
}

return result;

}

public BodyType getBodyType() { return BodyType.NONE; }

public OutputType getOutputType() { return OutputType.BLOCK; }

}

I would expect this:

2019-04-15 (3).png

But I get this:

2019-04-15 (4).png

Inspecting html source shows this:

<p>
<time datetime="2019-04-04" class="conf-macro output-block" data-hasbody="false" data-macro-name="helloworld"> </time>
</p>

Can anybody please give me a hint what I am doing wrong?

1 answer

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 17, 2019

Hello there!

Marcel, I took your HTML source for the picker and applied it to one of my local pages using the source editor:

Source Editor

After hitting apply, Confluence automatically changes the input to this:

<p>
<time datetime="2019-04-04"/>
</p>

And then the date picker is correctly shown.

You might need to check what and when this is being passed to Connie:

class="conf-macro output-block" data-hasbody="false" data-macro-name="helloworld"

Since this is excluded form the final result with the Source editor, I would imagine that this is what is breaking the date picker when you display it.

This could be hidden in what is returned by

map.get("Date");

Which is the value given to your date variable which is then concatenated with result and returned by your method.

 

Hopes this helps Marcel! Looking forward to your reply.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events