Products Downloads


French version


 

Apache FreeMarker is configured using the freemarker.properties file.

This configuration is mandatory in order to make FreeMarker work with your own templates.

 

The first step entails retrieving a copy of this file. See  MergeTransformMicroService page for more details.

This file is a Java .properties file (key syntax = value).

 

The second step entails changing or entering the keys according to requirements.

The only key that must be changed is the " template_loader" key, which is used to define the template loader.

 

Key

Description

template_loader

 

Template loader.

Default value:

freemarker.cache.MultiTemplateLoader( \

[com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")])

 

The "\" character indicates a line break in a key's value.

 

You need to add your own loader to the APE's default loader.

 

For example, if your user templates are in the "c:\myTemplates" directory:

template_loader=freemarker.cache.MultiTemplateLoader( \

[com.hardis.adelia.mergedocengine.freemarker.conf.FileTemplateLoader(java.io.File ("c:/myTemplates")), \

com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")])

 

Another example: if your user templates are in a JAR file located in the "/myTemplates" package (the JAR file must be present in the Java CLASSPATH):

template_loader=freemarker.cache.MultiTemplateLoader( \

[com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/myTemplates"), \

com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")])

 

default_encoding

 

Default encoding of templates read from a locale with no associated encoding.

Default value: UTF-8

 

template_update_delay

 

Defines the time in milliseconds that needs to elapse before the template cache management module checks whether there is a more recent version of a template than the one in the cache. The default value is 5 s.

 

In the template development phase, this value indicates the minimum wait time between when the template is saved (saving a change for example) and its availability to be processed (to test the result of the change) by the FreeMarker engine. So a value in the region of one second needs to be indicated.

 

In the production phase, it may be beneficial to have a very large value to avoid affecting the engine's performance under heavy load.

 

locale

 

Defines the locale used by default if no locale is specified in the Web services parameters.

 

template_exception_handler

 

Defines the error handling strategy during template processing.

Default value: "rethrow"

 

boolean_format

 

Defines the alphanumeric values used to convert a FreeMarker boolean value into an alphanumeric string in the ${ booleanValue } interpolation.

Default values: yes, no ("yes" for true and "no" for false)

 

extSharedVariables

 

Used to define one or more variables which are shared by all the templates.

The syntax must be a Map. For example: extSharedVariables = { "sharedNumberVar": 10, \

"sharedBoolVar": true, "sharedStringVar": "string value", \

"sharedDateVar": java.sql.Date(1531750144138), \

"sharedTimeVar": java.sql.Time(1531750144138), \

"sharedDateTimeVar": java.sql. Timesatmp(1531750144138), \

"sharedSequenceVar": [1, 2, 3], \

"sharedHashVar": { "subVar1": 1, "subVar2": false } \

}

 

These variables may be manipulated in the templates by using ${ sharedNumberVar }, ${sharedSequenceVar[1]} , $ {sharedHashVar.subVar1} interpolations, etc.

 

Important: if a level-one variable in the data model has the same name as a shared variable, the data model variable will "hide" the shared variable.

 

 

↑ Top of page

  • Aucune étiquette