loading table of contents...

4.3.4.4. Reference for FreeMarker Templates

The macros, functions and variables described in this section as well as any request, session, and servlet context scope attributes are implicitly available in any FreeMarker template view rendered by the CAE.

Macro / Function Parameters Description
@cm.include self: Object (required), view: String (optional), params: Hash (optional)

Render the object passed as "self" in the given view at this position in the output. Requires a template/view to be defined for such an object.

Examples:

<@cm.include self=self.navigation/>
<@cm.include self=self view="frame"/>
<@cm.include self=self view="overview" params={"details": false}/>
@cm.hook id: String (required), self: Object (optional, defaults to self object from template context), params: Hash (optional)

Renders the results of all com.coremedia.objectserver.view.events.ViewHookEventListener implementations that match the given type of self and that support the given id and the parameters.

Examples:

<@cm.hook id="htmlHead"/>
<@cm.hook id="pictureSubHeadline" self=self.picture/>
<@cm.hook id="teaserContainer" self=containerItem params={"isFirstInList": true}/>
cm.getLink() target: Object (required), view: String (optional, defaults to cm.UNDEFINED), params: Hash (optional): additional parameters given as a hash

Create a link to the object passed as "target" in the given view and return the URL as a string. Requires a link scheme to be defined for the target object. If the target object is cm.UNDEFINED, an empty string is returned.

Examples:

${cm.getLink(article, {"foo": 1})}
${cm.getLink(self, "asTeaser")}
${cm.getLink(article, "asTeaser", {"foo": 1})}
cm.getId() self: Object (required)

Determine this object's id through the IdProvider and return the id as a string.

Examples:

<input name="teaser" type="hidden" value="${cm.getId(teaser)}"/>
@cm.responseHeader name: String (required), value: String (required)

Set an HTTP response header. If the response is already committed, the macro will fail. Provided as part of the CAE library because this feature is missing in the standard FreeMarker Web integration.

Example:

<@cm.responseHeader name="Content-Type" value="text/html; charset=UTF-8"/>
cm.getRequestHeader() name: String (required)

Get an HTTP request header. Provided as part of the CAE library because this feature is missing in the standard FreeMarker Web integration.

Example:

<#if cm.getRequestHeader("Accept")?contains("application/xml")>...
@cm.metadata data: * (required)

Create a metadata attribute with a value containing a serialization of the given data. This function in covered in depth in section Section 4.3.5.2, “Metadata Support in FreeMarker Templates”.

Example:

<div class="foo"<@cm.metadata self.content/>>...
@cm.previewScripts

Enables the usage of the @cm.metadata macro and has to be included in the template once, before @cm.metadata can be used. For details see Section 4.3.5.2, “Metadata Support in FreeMarker Templates”.

Table 4.5. Implicit macros, functions and variables in FreeMarker templates