This example demonstrates how you can pass parameters to your macro. We'll create a font style macro which has two parameters to allows the user to specify the colour and size of the text contained in the macro body.

Before you start, see Writing user macros for an introduction to creating your own user macros. 

  1. Go to  > General Configuration > User Macros.
  2. Choose Create a User Macro.
  3. Enter the macro details (see table below)
  4. Choose Add.
FieldValue
Macro namestylish
VisibilityVisible to all users in the Macro Browser
Macro TitleStylish
DescriptionApplies colour and size to text.
CategoriesConfluence Content
Icon URLYou can leave this field blank
Documentation URLYou can leave this field blank
Macro body processingRendered
Template

Enter the code below in the template field. If your macro requires more than one parameter, you can use variables $param0 to $param9 to represent them.

## @param 0:title=colour|type=string
## @param 1:title=size|type=string
<span style="color: $param0; font-size: $param1">$body</span>

Alternatively, you can also use explicitly-named parameters in your macro. These macro parameters will appear as variables with the name $param<x> where <x> is the name of your parameter. 

## @param Colour:title=colour|type=string
## @param Size:title=size|type=string
<span style="color: $paramColour; font-size: $paramSize">$body</span>
  • No labels