Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get all macros on this page

BKippelt
Contributor
June 5, 2020

I wanted to get all page macros and get their body to use it for other pages.

 

@ComponentImport final XhtmlContent xhtmlContent 
public List<MacroDefinition> getPageMacros() throws XhtmlException {
if (xhtmlContent != null) {
final List<MacroDefinition> macros = new ArrayList<MacroDefinition>();
ContentEntityObject page = conversionContext.getEntity();
String pageContent = page.getBodyAsString();
xhtmlContent.handleMacroDefinitions(pageContent, conversionContext, new MacroDefinitionHandler() {
public void handle(MacroDefinition macroDefinition) {
macros.add(macroDefinition);
}
});
return macros;
}
return Collections.EMPTY_LIST;
}

 

I found this. Maybe this could help some other users.

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events