-1

Did not find an example or recommended use of {% block extraBody %}

Your thought please.

1 Answers1

0

The purpose of the extraBody nunjucks block in outerLayoutBase is to allow you to add code that you wish to place immediately before the closing </body> tag without being forced to override outerLayoutBase completely. You might, for instance, want to place third-party script tags here to avoid blocking rendering of the page while they load and run, if the script in question is not a good candidate for the async attribute.

Our goal with outerLayoutBase is to ensure that we insert Apostrophe's markup as part of a standardized base template that is flexible enough that people don't feel forced to override it and then have difficulty with markup we need to insert for Apostrophe later because they do not have the necessary template code in their stale copy of outerLayoutBase. Project level code should, if needed, start with an override of outerLayout that extends outerLayoutBase and just overrides a few blocks rather than reinventing the wheel. You'll note that the "stock" version of outerLayout is intentionally set up this way — it just extends outerLayoutBase and does nothing else. Your version can extend outerLayoutBase and override some blocks.

We encourage our own in-house developers to follow this rule, and to add new blocks to outerLayoutBase if they would otherwise be forced to override it, as a way of ensuring that other developers find the needed flexibility is there for them as well.

Tom Boutell
  • 7,281
  • 1
  • 26
  • 23