I was going through SDL doc as i need to integrate SDL Web 8.5 with DXA JAVA 2.0. came across this piece of code but didn't get it what it is used for. Also checked documentation and nothing was there. if anyone can point me in the right direction.

<dxa:pluggableMarkup label="top-js"/>

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>

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>
    <script src="${markup.versionedContent('/assets/scripts/xpm.js')}"></script>
<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 {

   private PluggableMarkupRegistry pluggableMarkupRegistry;

   @RequestMapping(method = RequestMethod.GET, value = "DoStuff/{entityId}")
   public String doStuff(...) {
      new ParsableHtmlNode("[a javascript snipper comes here]"));

Let me ping the DXA team to make sure we get this feature documented.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.