"Error occurred rendering template content" with User Macros

Hi all,

Before upgrading to Confluence v 5.10.5, my two custom User Macros worked fine. Here is the code of one of them:

 

## Macro name: number-of-comments
## Visibility: Visible only to system administrators in the Macro Browser
## Macro title: Number of comments
## Description: Returns the number of comments for a given page
## Categories: Confluence content, Reporting
## Macro body processing: No macro body
##
## Developed by: Nicolas Casel
## Date created: 03.07.2016
## Installed by: Nicolas Casel
## @param PageID:title=Page ID|type=int|required=false|desc=ID of page to count comments
##
## Check for page id parameter, otherwise use default of current page
#if (!$paramPageID)
#set ($paramPageID=$content.id)
#end
##
#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( $pageManager=$containerContext.getComponent('pageManager') )
#set( $commentManager=$containerContext.getComponent('commentManager') )
##
#set ($targetPage = $action.page)
## Set up integer object to handle string conversion of page id
#set($Integer = 0)
##
#if ($pageManager)
#set ($targetPage = $pageManager.getPage($Integer.parseInt($paramPageID)))
#end
##
#set($count = $commentManager.countComments($targetPage))
#if ($commentManager)
##<span class="commentcount">$count</span>
<aui-badge style="background-color: #d04437; color: white;">$count</aui-badge>
#end
#end

 

Since Confluence v 5.10.5, I get this message:

Error rendering macro 'number-of-comments' : Error occurred rendering template content

 

Any idea of the reason? Thank you!

 

1 answer

This widget could not be displayed.
Stephen Deutsch Community Champion Oct 27, 2016

The easiest way to see what is wrong is to look in the log file <confluence_home_directory>/logs/atlassian-confluence.log. Whenever it shows an "Error occurred rendering template content", there will be an accompanying entry in the log file with more details.

One thing you might try is to change 

#set ($targetPage = $action.page)

to

#set ($targetPage = $content)

The easiest way to see what is wrong is to look in the log file <confluence_home_directory>/logs/atlassian-confluence.log

Thanks for this insight.

In this case, I found the solution: removing the last:

#end

(last line)

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

601 views 8 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you