Professional Documents
Culture Documents
independent of servlet API JSP's are very much dependent on servlet API
while Magnolia template rendering is not. This is because Magnolia uses a
neutral context. By using Freemarker the rendering is independent of the
servlet container and can be executed isolated. This facilitates testing allows
nice things as diffs or request independent reaching of content.
templates are in the module's jar Currently all jsps must be extracted from
the module jar and copied to the webapp folder. This can be an obstacle as
the deployed webapp should normally not be changed on runtime (war
deployment). It is also cumbersome during the development process in
which one must copy the templates from the module resources to the
webapp (and back again).
security no critical code is stored in the file system and could be changed
expression language the expression language is very similar to the one of
freemarker and most of the templates will look very similar
Freemarker contd.
Built-ins
start_with, end_with
index_of
${abcabc?index_of(bc)} ==> 1
${abcabc?index_of(bc,2)} ==> 4
js_string
http://freemarker.sourceforge.net/docs/ref_builtins_string.html
Freemarker contd.
Built-ins
Freemarker contd.
Conditionals
Freemarker contd.
Loops
[#assign seq = ("mon", "tue", "wed", "thu")]
[#list seq as x]
${x_index + 1}. ${x?cap_first}[#if x_has_next],[/#if]
[/#list]
1. Mon,
2. Tue,
3. Wed,
4. Thu
Freemarker contd.
Include
[#include /another/cool/template/for/inclution.ftl]
Acquisition support
Freemarker contd.
#compress
#escape, #noescape
[#escape x as x?html]
First name: ${firstName}
Last name: ${lastName}
Maiden name: ${maidenName}
[/#escape]
Default variables
aggregationState aggregationState
Default variables
Template class
extends info.magnolia.cms.beans.config.Template
Template model
extends
info.magnolia.cms.beans.config.RenderingModelImpl
Few examples:
<a href="javascript:alert('$
{i18n['link.document.resolveError']?js_string}')">$
{i18n['link.document.resolveError']}</a>
[#assign teaserLink=model.teaserLink!""]
[#if !hideTeaserImage]
[#assign imageLink=model.imageLink!""]
[/#if]
[#if imageLink?has_content]
[#assign imageAlt=title]
[#else]
[#assign imageAlt="${i18n['image.resolveError']}"]
[/#if]