Example User Macro - Colour and Size

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.
Field Value
Macro name stylish
Visibility Visible to all users in the Macro Browser
Macro Title Stylish
Description Applies colour and size to text.
Categories Confluence Content
Icon URL You can leave this field blank
Documentation URL You can leave this field blank
Macro body processing Rendered

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>

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport