Core content macros help creating pages that are rendered using dynamic content.
Macros with readers help formatting data on properties, XML and JSON files.
Expands into web application's context.
Shows current rendering context.
Calls modules' user summaries and show the results.
{@
user-summary
[
:
mode
]
}
Attributes |
Description |
Options |
Default |
mode |
Mode to use.
|
init
|
|
Reads and renders file content.
{@
include
:
content-file
}
Attributes |
Description |
Options |
Default |
content-file |
System file to show.
|
|
|
Writes parameter with name value or default when null.
{@
param
:
name
[
:
default
]
}
Attributes |
Description |
Options |
Default |
name |
Attribute name.
|
|
|
default |
Default value.
|
|
|
Renders context content. If stopper is set to true, stops when finding a line starting with .
{@
render
:
context
[
:
stopper
]
}
Attributes |
Description |
Options |
Default |
context |
Elephant context for links.
|
|
|
stopper |
Whether rendering should stop.
|
|
|
Writes current date, time or both using diferent localized formats.
{@
date
[
:
mode
[
:
format
]
]
}
Attributes |
Description |
Options |
Default |
mode |
Mode to use.
|
date,
all,
time
|
date
|
format |
Format used to show the value.
|
short,
medium,
long,
full
|
short
|
Renders the feed at url.
Attributes |
Description |
Options |
Default |
url |
Uniform Resource Locator.
|
|
|
Creates an Elephant marker within context with name. Elephant markers are initialized with correct locale and constructor as variable.
{@
marker
:
tmpl-root
:
template
:
value-map
}
Attributes |
Description |
Options |
Default |
tmpl-root |
Templates root.
|
|
|
template |
Template used to show the items.
|
|
|
value-map |
Values using the form variable=value separated by ;
|
|
|
Creates an Elephant marker within context with name. The repository-file is stored in props
.
{@
marker-props
:
tmpl-root
:
template
:
repository-file
}
Attributes |
Description |
Options |
Default |
tmpl-root |
Templates root.
|
|
|
template |
Template used to show the items.
|
|
|
repository-file |
Name of the repository file.
|
|
|
Creates an Elephant marker within context with name. The repository-file is stored in doc
.
{@
marker-xml
:
tmpl-root
:
template
:
repository-file
}
Attributes |
Description |
Options |
Default |
tmpl-root |
Templates root.
|
|
|
template |
Template used to show the items.
|
|
|
repository-file |
Name of the repository file.
|
|
|
Creates an Elephant marker within context with name. The repository-file is stored in json
.
{@
marker-json
:
tmpl-root
:
template
:
repository-file
}
Attributes |
Description |
Options |
Default |
tmpl-root |
Templates root.
|
|
|
template |
Template used to show the items.
|
|
|
repository-file |
Name of the repository file.
|
|
|
Writes a json array of files matching path and pattern. The array can be as is, sorted or shuffled.
{@
files
:
folder
:
pattern
:
mode
}
Attributes |
Description |
Options |
Default |
folder |
Folder location.
|
|
|
pattern |
The pattern items must match.
|
|
|
mode |
Mode to use.
|
normal,
sort,
shuffle
|
|
Creates a frame with url content. If url starts with '/' application context is automatically inserted.
{@
frame
:
url
:
width
:
height
}
Attributes |
Description |
Options |
Default |
url |
Uniform Resource Locator.
|
|
|
width |
CSS style width.
|
|
|
height |
CSS style height.
|
|
|
Gets resource value and renders as mode. Mode is an integer optional parameter.
{@
res
:
resource-key
[
:
string-mode
]
}
Attributes |
Description |
Options |
Default |
resource-key |
Key used to locate de resource.
|
|
|
string-mode |
Possible values are: 0 No transform, 1 Capitalized, 2 To upper case, 3 To lower case.
|
|
0
|
{@
i18n
:
resource
[
:
string-mode
]
}
Attributes |
Description |
Options |
Default |
resource |
|
|
|
string-mode |
Possible values are: 0 No transform, 1 Capitalized, 2 To upper case, 3 To lower case.
|
|
0
|
Writes a random number starting at zero and up to limit minus one.
{@
random
:
random-limit
}
Attributes |
Description |
Options |
Default |
random-limit |
Random values ceil.
|
|
|
Elephant context for links.
Attributes |
Description |
Options |
Default |
level |
Number of the item level.
|
|
|
Writes currently logged user's name, identifier or email.
Attributes |
Description |
Options |
Default |
mode |
Mode to use.
|
name,
id,
email
|
name
|
Writes true or false expressions depending on whether role:attribute pair are satisfied.
{@
if
:
role
:
attribute
:
true-expression
:
false-expression
}
Attributes |
Description |
Options |
Default |
role |
Entity role part.
|
|
|
attribute |
Permission part.
|
|
|
true-expression |
When comparison is true.
|
|
|
false-expression |
When comparison is false.
|
|
|
Writes true or false expressions depending on whether cookie value equals value.
{@
ifcookie
:
cookie
:
value
:
true-expression
:
false-expression
}
Attributes |
Description |
Options |
Default |
cookie |
Cookie name.
|
|
|
value |
Value to search for.
|
|
|
true-expression |
When comparison is true.
|
|
|
false-expression |
When comparison is false.
|
|
|
Writes true or false expressions depending on whether class could be instantiated.
{@
class
:
class-name
:
true-expression
:
false-expression
}
Attributes |
Description |
Options |
Default |
class-name |
Java class name.
|
|
|
true-expression |
When comparison is true.
|
|
|
false-expression |
When comparison is false.
|
|
|
Writes true or false expressions depending on whether value1 equals value2.
{@
equals
:
value
:
value
:
true-expression
:
false-expression
}
Attributes |
Description |
Options |
Default |
value |
Value to search for.
|
|
|
value |
Value to search for.
|
|
|
true-expression |
When comparison is true.
|
|
|
false-expression |
When comparison is false.
|
|
|
Renders object's attribute as string. object
can also be an entityPath.
{@
object
:
ref-object
:
attribute
}
Attributes |
Description |
Options |
Default |
ref-object |
Attribute name holding the object or an entityPath .
|
|
|
attribute |
Renders attribute's value as string.
|
|
|
Renders attribute's value as string.
{@
attribute
:
attribute
[
:
format
]
}
Attributes |
Description |
Options |
Default |
attribute |
Renders attribute's value as string.
|
|
|
format |
Format used to show the value.
|
|
|
Renders entity using name and description.
{@
entity
:
entityPath
:
fmt-name-desc
}
Attributes |
Description |
Options |
Default |
entityPath |
Path to a entity.
|
|
|
fmt-name-desc |
Format, as in String.format(), with entity name and description as parameters.
|
|
|
Renders the entity represented by path calling plugin and using template if specified.
{@
entity-ctrl
:
plugin
:
entityPath
[
:
template
]
}
Attributes |
Description |
Options |
Default |
plugin |
Plugin name.
|
|
|
entityPath |
Path to a entity.
|
|
|
template |
Template used to show the items.
|
|
|
Writes cookie value. If optional value is defined, then sets cookie value.
{@
cookie
:
name
[
:
value
]
}
Attributes |
Description |
Options |
Default |
name |
Attribute name.
|
|
|
value |
Value to be set when defined.
|
|
|
Indicator name.
{@
indicator
:
storeClass
:
indicatorClass
:
entityPath
:
indicator
[
:
relatedPath
]
}
Attributes |
Description |
Options |
Default |
storeClass |
|
|
|
indicatorClass |
|
|
|
entityPath |
Path to a entity.
|
|
|
indicator |
Indicator name.
|
|
|
relatedPath |
|
|
|
{@
entry-point
:
identifier
[
:
values
]
}
Attributes |
Description |
Options |
Default |
identifier |
|
|
|
values |
|
|
|
Macros with readers, how does it work?
The easiest way to read a file is store it in context's repository and access it with */file
. The *
will expand into rendering context repository. For example:
{@marker-xml:xml:doc:*/doc.xml}
Reads doc.xml
in current repository and passes its data to [Template_root]/xml/docTemplate.html
to be formatted.
Reading properties
Properties are stored in props
list in the same order they are stored on disc. You can iterate props with #list
.
<#list props?keys as key>
<#assign value=props[key]/>
// do something with key and value
...
< /#list>
Reading XML
XML documents are stored in doc
model. You can iterate the elements using dot syntax and iterate collections as you would usually do for any other data. The XML model is the FreeMarker NodeModel.
Reading JSON
JSON files are stored in json
model. To access a root, use json.read("$.root")
. If the root is a list, use json.list("$.root")
. Once retrieved the root, you can iterate the elements using dot syntax and iterate collections as you would usually do for any other data. The JSON model is a subset of the JsonPath DocumentContext, optimized for templates usage.
The JSON books
example
The data:
{
"book": [
{
"title": "...",
"author": "...",
"excerpt": "...",
"availability": "...",
"link": "...",
"filelink": "...",
"imagelink": "...",
"pages": 0
},
{
...
},
...
]
}
The template (Semantic-UI):
<div class="ui divided items">
<#list json.list("$.book") as book>
<div class="item">
<a class="ui tiny image" href="${book.link}">
<img src="${book.imagelink}"/>
</a>
<div class="content">
<a class="header" href="${book.link}">${book.title}</a>
<div class="meta">
${book.author}
</div>
<div class="description">
${book.excerpt}
</div>
<div class="extra">
${book.availability}
<#if book.filelink?has_content>
<a target="_new" href="${book.filelink}">${book.pages}</a>
< /#if>
</div>
</div>
</div>
< /#list>
</div>