Is there a good resourse for learning to write user macros?

Kris Fininen December 13, 2019

We want to write a user macro to style certain numbered lists with alpha characters. We need a macro rather than just forcing a level 2 list in the source code or creating a style because we also output our documents using K15t Scroll PDF Exporter. In PDF Exporter numbered list styles can be styled in the template, but only for the entire document. K15t tells us that the exporter will maintain styles set in a user macro. So ... we need a user macro to style a numbered list with lower alpha characters.

K15t sent the following as an example, but we don't know enough to change the #set area of the macro. Looks like this might be a timestamp macro? You see our problem. WE understand everything that comes after <style>.

## @noparams

#set ($timestamp = $action.dateFormatter.calendar.timeInMillis)
#set ($uniqueClass = "list-${timestamp}")

<style>
.${uniqueClass} ol {
list-style-type: lower-alpha !important;
}
</style>
<div class="${uniqueClass}">
$body
</div>

1 answer

0 votes
Dominic Lagger
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.
December 14, 2019

Hi @Kris Fininen 

There is one overview site, which let you know more about user macros:

I've had some programming skills but no clue about velocity. I learnt velocity just by try and error and the API

Confluence uses velocity as the script language. On the linked page, velocity is explained quite good. 

In your case:

  • The "#set" is to define a variable. 
  • The "$action.dateFormatter.calendar.timeInMillis" sets the actual time in milliseconds to the variable $timestamp
  • The "#set ($uniqueClass = "list-${timestamp}")" defines a unique class, which will be referenced in the HTML and the CSS, which you understand


Hope this gives you a good overview. If you need any help, let me know.

Regards, Dominic

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events