FreeMarker (Alfresco)

Referencia: http://wiki.alfresco.com/wiki/Template_Guide

El API FreeMarker de Alfresco es una vista orientada a objetos de la Java Foundation API específicamente diseñada para ser utilizada en plantillas FreeMarker.

Root objects

companyhome The Company Home template node

userhome The current user's Home Space template node

person A node representing the current user's Person object

space The current space template node (if you are accessing the templates through the Space Preview action)

document The current document's template node (if you are accessing the templates through the Document Preview action)

template The node representing the template itself

args A map of any URL parameters passed via the Template Content Servlet (only available if the template was executed via the servlet)

session Session-related information (session.ticket for the authentication ticket)

classification Read access to classifications and root categories

Template node objects

properties A map of the properties of the node. For example userhome, properties, name.

Properties may return several different types of objects. This depends entirely on the underlying property type in the repository. If the property is multi-valued, then the result will be a sequence, which can be indexed as for any other sequence or array.

children A sequence (list) of the child nodes. For example, a list of the documents in a space.

url The URL of the content stream of this node.

content Returns the content of the node as a string.

size The size, in bytes, of content attached to this node.

isLocked True if the node is locked, false otherwise.

name Shortcut access to the name property.

parent The parent node, it can be null if this is the root node.

childrenByXPath Returns a map capable of executing an XPath query in order to find child nodes, for example,

companyhome.childrenByXPath["*[@cm:name='Data Dictionary']/*"]

childByNamePath Returns a map capable of returning a single child node found by the name path, for example,

companyhome.childByNamePath["Data Dictionary/Content Templates"]

Directives

#if, #else, #elseif

#switch, #case

#list

#assign

#function

#include

<#-- comment -->

Default Model Methods

Custom template methods can be added to the FreeMarker language for use on template pages. The default model provides the following additional methods:

hasAspect(TemplateNode, String) - will return the integer value 1 if the TemplateNode supplied has the aspect with the supplied QName String, else the integer value 0 will be returned.

dateCompare(DateA, DateB) - Compare two dates to see if they differ. Returns 1 if DateA if greater than DateB, else returns 0.

dateCompare(DateA, DateB, Number) - Compare two dates to see if they differ by the specified number of milliseconds. Returns 1 if DateA is greater than DateB by at least the Number value in milliseconds, else returns 0.

dateCompare(dateA, dateB, millis, test) - Same as above, but the 'test' variable is one of the following strings ">", "<", "==" - greater than, less than or equal - as the test to perform.

incrementDate(date, millis) - Increment a date by the specified number of milliseconds, returns the new Date.

message(String) - will return the I18N message string (resolved for current user Locale setting) for the specified String message ID.

cropContent(TemplateNode, length) - returns the first N characters from the content stream for the specified node.

'shortQName(String) - returns the short, or prefix, version of a long QName.