Skip to content

Instantly share code, notes, and snippets.

@xeor
Created January 28, 2016 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeor/631c0b0b29c5d80074bb to your computer and use it in GitHub Desktop.
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
## 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