"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

1 vote
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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

487 views 19 10
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