Display Macro should display the referenced content in a div with a certain class

I am working with the Display Macro.
When I display a referenced page, I would like to have the inserted content in a div, eg.
<div class="DisplayMacro">content of the referenced page</div>

That way, I can add CSS to display a coloured frame, or to add a Javascript event that will open the referenced page in a separate window.

I tried to copy the extension and add this additional div, and it works.
Basically, I wrap the whole output into a GroupBlock.
See the diff here:

Is this worth considering that I should create an issue and pull request for the DisplayMacro?

Or should I file an issue first?

Our policy is to always reference an issue in the commit log (except of course of very minor commit which don’t really have a functional impact from user point of view). So yes, would be great if you could start by creating a Jira issue about that so that you can mention it in your commit/pull request.

I’m not convinced that this should be done in the Display Macro. It may even break some places where the code using the display macro doesn’t expect any wrapping. Can’t you do this from outside of the display macro:

(% class="display-macro-wrapper" data-reference="Path.To.Page" %)(((
  {{display reference="Path.To.Page" /}}

And if you need this in multiple places then you can create your own rendering macro that wraps the display macro. See https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/WikiMacroTutorial/ .

If we add the wrapping inside the display macro (although I’m not convinced it’s a good idea) I think it should be configurable and disabled by default.

Thank you for your reply.

It is in quite a few places, and my users are not into editing the code.

Thanks for the reference to the XWiki Rendering Macros, I will look into that.