Created
January 28, 2016 11:22
-
-
Save xeor/631c0b0b29c5d80074bb to your computer and use it in GitHub Desktop.
A tiny confluence user-macro to set a page property based on the output of another macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Macro title: Add macro output as property | |
## Macro has a body: Y | |
## Body processing: Convert macrooutput to page property. Visible in example bobswift's "run" macro as %property_varname% | |
## Output: Variable | |
## | |
## Developed by: Lars Solberg | |
## Date created: 25/01/2016 | |
## Installed by: Lars Solberg | |
## @param Name:title=Name|type=string|required=true|desc=Name of property to create | |
#set ($containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager')) | |
#set ($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null)) | |
#set ($containerManager=$getInstanceMethod.invoke(null,null)) | |
#set ($containerContext=$containerManager.containerContext) | |
#set ($contentPropertyManager=$containerContext.getComponent('contentPropertyManager')) | |
#if ($body) | |
$contentPropertyManager.setStringProperty($content, "$paramName", $body.trim()) | |
#else | |
$contentPropertyManager.setStringProperty($content, "$paramName", "") | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment