This is used to inject markup from entity views to placeholders in page views, for example additional CSS/JS includes, JS snippets to be executed after jQuery has been initialised etc. This makes it easier to make DXA modules more self-contained when it comes to needed resources. This is used for example in the Instant Campaign module to inject campaign specific CSS/JS to the page.
Example of use in an entity view:
<dxa:definePluggableMarkup label="bottom-js">
<script src="/my-assets/scripts/myadditionaljs.js"></script>
</dxa:definePluggableMarkup>
Then the markup code within the dxa:definePluggableMarkup tag is injected into the page view when it gets rendered. For example:
<script src="${markup.versionedContent('/assets/scripts/main.js')}"></script>
<xpm:if-enabled>
<script src="${markup.versionedContent('/assets/scripts/xpm.js')}"></script>
</xpm:if-enabled>
<dxa:pluggableMarkup label="bottom-js"/>
Above then gets rendered to:
<script src="/system/v2.0/assets/scripts/main.js"></script>
<script src="/system/v2.0/assets/scripts/xpm.js"></script>
<script src="/my-assets/scripts/myadditionaljs.js"></script>
In addition you can also inject markup directly from the Java code (for example in a controller):
public class MyController extends BaseController {
@Autowired
private PluggableMarkupRegistry pluggableMarkupRegistry;
@RequestMapping(method = RequestMethod.GET, value = "DoStuff/{entityId}")
public String doStuff(...) {
...
this.pluggableMarkupRegistry.registerContextualPluggableMarkup("bottom-js",
new ParsableHtmlNode("[a javascript snipper comes here]"));
}
}
Let me ping the DXA team to make sure we get this feature documented.