Skip to content

EN.03.04.01.Freemarker Specification

stormcat24 edited this page Aug 12, 2014 · 1 revision

template.yaml

In the case of Freemarker, locate template.yaml at project root directory, as follows.

freemarker:
  # aeromock original setting
  extension: .ftl
  autoEscape: false

  # freemarker settings
  autoFlush: false
  objectWrapper: BEANS_WRAPPER
  autoIncludes: []
  booleanFormat: "true,false"
  classicCompatible: false
  #dateFormat:
  dateTimeFormat: "yyyy-MM-dd HH:mm:ss"
  defaultEncoding: "UTF-8"
  localizedLookup: true
  numberFormat: "###"
  outputEncoding: "UTF-8"
  strictBeanModels: false
  strictSyntaxMode: true
  tagSyntax: 0
  # AUTO_DETECT_TAG_SYNTAX = 0
  # ANGLE_BRACKET_TAG_SYNTAX = 1
  # SQUARE_BRACKET_TAG_SYNTAX = 2
  #templateUpdateDelay: 5000
  # timeFormat: "HH:mm:ss"
  urlEscapingCharset: "UTF-8"
  whitespaceStripping: true
  # BIGDECIMAL_ENGINE(default)|CONSERVATIVE_ENGINE
  arithmeticEngine:
  autoImports:
    spring: common/spring.ftl
name content default value
extension extension of template .ftl
autoEscape whether to insert escape tag or not false
objectWrapper Implementation of ObjectWrapper (BEANS_WRAPPER, STRUTS2_BEANS_WRAPPER, SIMPLE_WRAPPER, DEFAULT_WRAPPER) DEFAULT_WRAPPER
autoIncludes TODO TODO
booleanFormat TODO TODO
classicCompatible TODO TODO
dateTimeFormat TODO TODO
defaultEncoding TODO TODO
localizedLookup TODO TODO
numberFormat TODO TODO
outputEncoding TODO TODO
strictBeanModels TODO TODO
strictSyntaxMode TODO TODO
tagSyntax TODO TODO
templateUpdateDelay TODO TODO
timeFormat TODO TODO
urlEscapingCharset TODO TODO
whitespaceStripping TODO TODO
arithmeticEngine TODO BIGDECIMAL_ENGINE
autoImports map of macro definitions Empty list

Extended Specification on Aeromock

.now

.now is builtin variable of Freemarker. Be able to define current time object .now returns. Define property of __now at top level in data file.

prop1: propValue
__now: 2014-06-01T00:00:00+09:00

Various use cases

Import macro

Define various macro at autoImports at template.yaml

For example, int the case of Spring macro, locate spring.ftl to any directory. If path is template_root/common/spring.ftl, as follows.

autoImports:
  spring: common/spring.ftl

This macro is named spring, so refer to the following.

<ul>
	<li>@spring.message = <@spring.message "site.title" /></li>
	<li>@spring.message = <@spring.url "/aaa" /></li>
</ul>

You have to create data of springMacroRequestContext at the target data file, because springMacroRequestContext is defined in this macro.

springMacroRequestContext:
  __methods:
    - name: getMessage
      value: hogehoge
    - name: getContextUrl
      value: http://${HOST}/aaa
Clone this wiki locally