Confluence 3.5 : Examples of User Macros
This page last changed on Oct 11, 2010 by smaddox.
Below are some sample user macros. To see how to write a user macro and add it to your Confluence site, take a look at our guide to writing user macros. On this page: Examples of Working User MacrosThese user macros are examples that you may want to install onto your Confluence site. Working Example 1: The Expand MacroSee Writing the Expand User Macro. Working Example 2: The Status MacroSee Writing the Status User Macro. Simple and Illustrative Examples of User MacrosWe provide these user macros as simple examples just to get you started. You would not want to install these user macros onto your Confluence site. Simple Example 1: User Macro to Display 'Hello World'Take a look at an example of a 'Hello World' macro. Simple Example 2: The 'Error' User Macro to Create a Red BoxLet's write a simple macro that creates a red box (using an existing Confluence style) around some text. This may be useful for writing about error conditions, for example. That is why we give this macro the name 'error'. To create the 'Error' user macro,
To use the macro within a page, add wiki markup like this: {error}This is bad{error} Your page will display an error box, like this: This is bad Simple Example 3: User Macro to Demonstrate the Use of ParametersThis example demonstrates how you can pass parameters into your macro. Let's say you want to write your own font colour macro: <span style="color: $param0">$body</span> The usage of this macro will be: {colour:green}Some example text{colour} The output will be: If your macro requires more than one parameter, you can use variables $param0 to $param9 to represent them. To specify multiple parameters, use: {colour:red|blue|green} Where red, blue and green are the 1st, 2nd and 3rd parameters respectively. 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. To specify named parameters, use: {style:colour=red} In your user macro you can then use $paramcolour which will have the value red in this case. User-Contributed User MacrosYou may want to take a look at the library of user-contributed user macros. |
![]() |
Document generated by Confluence on Mar 16, 2011 18:31 |