Define the RequireJS Module

You can define a RequireJS module in the render.js file. Sites loads the dependencies, such as for JQuery, Mustache, the RequireJS Text Plugin, and the RequireJS CSS plugin.

define([
		'jquery',
		'mustache',
		'text!./layout.html',
		'css!./design.css'
], function ($, Mustache, templateHtml, css) {

You can use the Mustache template system to render the layout.

The assets/render.js file for a content layout has the following properties:

  • It should be a RequireJS module

  • It should return a JavaScript Constructor function. Sites invokes the Constructor function by passing a parameter object. The parameter object has the content item data and the APIs required to render the layout.

  • This Constructor function should have a render(parentObj) method that handles rendering the content layout. It should append the content layout DOM object to the parentObj object that is passed to the render()method.

  • The RequireJS module can use the dependencies, including JQuery, Mustache, the RequireJS Text Plugin, and the RequireJS CSS plugin. These dependencies will be loaded by sites. You can use other libraries too.