#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- FreeMarker samples -->
<#import "lib-datetime.ftl" as dt>
<#import "lib-string.ftl" as str>
${title}
<@widget name="test" />
Dates
- Current date & time: ${now?datetime}
- Current date: ${now?date}
- Current time: ${now?time}
Dates
Formatted datetime
${dt.xsdDateTimeToYear(xsddatetime)}
Apples
<#list apples as apple>
- ${apple}
#list>
Fruit
<#list fruit as f>
- ${f}
#list>
Animal: ${animal}
Book Title: ${bookTitle}
Zoo 1
<#list zoo1.animals as animal>
- ${animal}
#list>
Zoo 2
<#list zoo2.animals as animal>
- ${animal}
#list>
Berries: ${berries}
${year?number?c}
Raw String Literals
${r"#{title}"}
${r"${title}"}
Containers do not pick up changes to the value of their elements
<#assign
fruit = ["apples", "oranges", "bananas"]
veg = ["beans", "peas", "carrots"]
food = [fruit, veg]
fruit = fruit + ["pears"]
>
<#noparse>
<#assign
fruit = ["apples", "oranges", "bananas"]
veg = ["beans", "peas", "carrots"]
food = [fruit, veg]
fruit = fruit + ["pears"]
>
#noparse>
List elements of ${r"${fruit}"}
<#list fruit as f>
${f}
#list>
List elements of ${r"${food}"}: contains no pears
<#list food as item>
<#list item as i>
${i}
#list>
#list>
Numbers
<#assign
one = 1
two = 2
numbers = [one, two]
two = 20
numbers2 = [one, two]
>
<#noparse>
<#assign
one = 1
two = 2
numbers = [one, two]
two = 20
numbers2 = [one, two]
>
#noparse>
${r"${two}"}: ${two}
${r"${numbers[1]}"}: ${numbers[1]}
${r"${numbers2[1]}"}: ${numbers2[1]}
Uncamelcasing
<#assign s1 = "FreemarkerTest">
${s1} => ${str.unCamelCase(s1)}
<#assign s2 = "Freemarker">
${s2} => ${str.unCamelCase(s2)}
<@dump var="now" />
<@dump var="urls" />
<@dump var="fruit" />
<@dump var="trueStatement" />
<@dump var="zoo1" />
<@dump var="pojo" />
${stylesheets.addFromTheme("/css/sstest.css", "/css/sstest2.css")}
${scripts.addFromTheme("/js/jstest.js")}
${scripts.add("/js/script1.js", "/js/script2.js", "/js/script3.js")}
<@dumpAll />
<@help for="dump" />
<@help for="profileUrl" />
<@describe var="stylesheets" />