Render Content Items

Content Layouts are used to render content items. They receive the content item data, render it into HTML, and insert it onto the page.

By default, content layouts leverage Mustache templating to render content items, although they can be implemented in any JavaScript technology. For the Mustache template to render, it expects the data to be in a certain format. The content layout render.js file needs to ensure that the model it passes to the template matches that format.

Content layouts are rendered in several use cases:

  • When used in the Oracle Content and Experience Asset Management UI, the data can be in an "edited" state for the user to preview changes before saving them.

  • When used in an Oracle Content and Experience site in a content list or content item, the data is augmented with additional information about the site in which it is running.

  • When used through the Content SDK's contentClient.renderLayout() call, where the user of the Content SDK passes whatever data they want directly to the content layout.

For performance, there is a general trade-off between creating a single query that can return all required data or multiple queries so that the outline renders as fast as possible, with a fast initial query, and areas are subsequently filled in through subsequent queries. Which model you choose depends on your data and use cases.

Also, the data passed to a content layout can vary in format due to how the data was retrieved. For example, if you use a content REST with an expand parameter, field references to other content items, either individually or as a group, can also be returned. If the referenced content items aren't included, you'll need to make additional REST calls.

To handle all cases, the content layout developer should attempt to be flexible about the format of received data. Also, when necessary, the developer can fetch additional data and coerce the data into the format expected by the rendering template.